From f8241d8bdaa17c01098e2a7a130b396847276808 Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 12 Feb 2018 23:47:27 +0100 Subject: [PATCH 1/3] Define string_types in compat.py --- moviepy/compat.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/moviepy/compat.py b/moviepy/compat.py index ceac4d312..7a007e56c 100644 --- a/moviepy/compat.py +++ b/moviepy/compat.py @@ -2,7 +2,12 @@ import sys PY3=sys.version_info.major >= 3 -if PY3: - from subprocess import DEVNULL # py3k -else: - DEVNULL = open(os.devnull, 'wb') +try: + string_types = (str, unicode) +except NameError: + string_types = (str) + +try: + from subprocess import DEVNULL # Python 3 +except ImportError: + DEVNULL = open(os.devnull, 'wb') # Python 2 From 12eef3a016ff91eed0dc054d6e4b97fdbf6cabc1 Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 12 Feb 2018 23:51:25 +0100 Subject: [PATCH 2/3] Use string_types in VideoClip.py --- moviepy/video/VideoClip.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py index 0744bef90..5f7a6285f 100644 --- a/moviepy/video/VideoClip.py +++ b/moviepy/video/VideoClip.py @@ -14,7 +14,7 @@ from tqdm import tqdm from ..Clip import Clip -from ..compat import DEVNULL, PY3 +from ..compat import DEVNULL, string_types from ..config import get_setting from ..decorators import (add_mask_if_none, apply_to_mask, convert_masks_to_RGB, convert_to_seconds, outplace, @@ -896,12 +896,8 @@ def __init__(self, img, ismask=False, transparent=True, fromalpha=False, duration=None): VideoClip.__init__(self, ismask=ismask, duration=duration) - if PY3: - if isinstance(img, str): - img = imread(img) - else: - if isinstance(img, (str, unicode)): - img = imread(img) + if isinstance(img, string_types): + img = imread(img) if len(img.shape) == 3: # img is (now) a RGB(a) numpy array From 56f7604a8a34228840307e0705c61556497b7a91 Mon Sep 17 00:00:00 2001 From: cclauss Date: Mon, 12 Feb 2018 23:54:56 +0100 Subject: [PATCH 3/3] Fix comments --- moviepy/compat.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moviepy/compat.py b/moviepy/compat.py index 7a007e56c..0404e57f6 100644 --- a/moviepy/compat.py +++ b/moviepy/compat.py @@ -3,9 +3,9 @@ PY3=sys.version_info.major >= 3 try: - string_types = (str, unicode) + string_types = (str, unicode) # Python 2 except NameError: - string_types = (str) + string_types = (str) # Python 3 try: from subprocess import DEVNULL # Python 3