Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve undefined name unicode in Python 3 #717

Merged
merged 3 commits into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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