Skip to content

Video editing with Python

Resolve undefined name execfile in Python 3

cclauss62523df7a8fe
diff --git a/moviepy/config.py b/moviepy/config.py
index 7258723c..4743ca57 100644
--- a/moviepy/config.py
+++ b/moviepy/config.py
@@ -5,7 +5,7 @@ from .compat import DEVNULL
if os.name == 'nt':
try:
import winreg as wr # py3k
- except:
+ except ImportError:
import _winreg as wr # py2k
from .config_defaults import (FFMPEG_BINARY, IMAGEMAGICK_BINARY)
@@ -68,7 +68,6 @@ else:
"be wrong: %s" % (err, IMAGEMAGICK_BINARY))
-
def get_setting(varname):
""" Returns the value of a configuration variable. """
gl = globals()
@@ -79,18 +78,19 @@ def get_setting(varname):
return gl[varname]
-def change_settings(new_settings=None, file=None):
+def change_settings(new_settings=None, filename=None):
""" Changes the value of configuration variables."""
- if new_settings is None:
- new_settings = {}
+ new_settings = new_settings or {}
gl = globals()
- if file is not None:
- execfile(file)
+ if filename:
+ with open(filename) as in_file:
+ exec(in_file)
gl.update(locals())
gl.update(new_settings)
# Here you can add some code to check that the new configuration
# values are valid.
+
if __name__ == "__main__":
if try_cmd([FFMPEG_BINARY])[0]:
print( "MoviePy : ffmpeg successfully found." )