Skip to content

Commit

Permalink
Resolve undefined name unicode in Python 3
Browse files Browse the repository at this point in the history
Resolve undefined name unicode in Python 3
  • Loading branch information
tburrows13 committed Feb 13, 2018
2 parents 913e618 + 56f7604 commit 30e3642
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
13 changes: 9 additions & 4 deletions moviepy/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) # Python 2
except NameError:
string_types = (str) # Python 3

try:
from subprocess import DEVNULL # Python 3
except ImportError:
DEVNULL = open(os.devnull, 'wb') # Python 2
10 changes: 3 additions & 7 deletions moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 30e3642

Please sign in to comment.