execfile in python 3 and 2
authorymh <ymh.work@gmail.com>
Mon, 08 Jun 2015 00:37:27 +0200
changeset 128 d4e5954f2ad4
parent 127 036781323559
child 129 509d7a4c0a2b
execfile in python 3 and 2
server/setup.py
--- a/server/setup.py	Mon Jun 08 00:35:47 2015 +0200
+++ b/server/setup.py	Mon Jun 08 00:37:27 2015 +0200
@@ -48,18 +48,15 @@
     version_variables = {}
     local_variables = {}
     try:
-        execfile(os.path.join(source_dirs[0], "__init__.py"), version_variables)
+        with open("somefile.py") as f:
+            code = compile(f.read(), "somefile.py", 'exec')
+            exec(code, version_variables, local_variables)
     except:
-        try:
-            with open("somefile.py") as f:
-                code = compile(f.read(), "somefile.py", 'exec')
-                exec(code, version_variables, local_variables)
-        except:
-            print("Exception in user code:")
-            print("-"*60)
-            traceback.print_exc(file=sys.stdout)
-            print("-"*60)
-            pass
+        print("Exception in user code:")
+        print("-"*60)
+        traceback.print_exc(file=sys.stdout)
+        print("-"*60)
+        pass
 
     version = version_variables['__version__']