]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Make exec to work on both 2 and 3
authorHong Minhee <minhee@dahlia.kr>
Fri, 12 Apr 2013 19:26:24 +0000 (04:26 +0900)
committerHong Minhee <minhee@dahlia.kr>
Fri, 12 Apr 2013 19:26:24 +0000 (04:26 +0900)
alembic/util.py

index 826247f65e2a4f3be6ed46381a525974f5be9387..c7c3784a7094578c185358ad6f5f71e420e44569 100644 (file)
@@ -1,5 +1,9 @@
 from __future__ import with_statement
 
+try:
+    import builtins
+except ImportError:
+    import __builtin__ as builtins
 import sys
 import os
 import textwrap
@@ -114,7 +118,13 @@ def create_module_class_proxy(cls, globals_, locals_):
             'doc': fn.__doc__,
         })
         lcl = {}
-        exec func_text in globals_, lcl
+        try:
+            exec_ = getattr(builtins, 'exec')
+        except AttributeError:
+            # Python 2
+            def exec_(func_text, globals_, lcl):
+                exec('exec func_text in globals_, lcl')
+        exec_(func_text, globals_, lcl)
         return lcl[name]
 
     for methname in dir(cls):