From 34b3aaf7e68fe9edfa9bc06ff033fec1c97c09ed Mon Sep 17 00:00:00 2001 From: Hong Minhee Date: Sat, 13 Apr 2013 04:26:24 +0900 Subject: [PATCH] Make exec to work on both 2 and 3 --- alembic/util.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/alembic/util.py b/alembic/util.py index 826247f6..c7c3784a 100644 --- a/alembic/util.py +++ b/alembic/util.py @@ -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): -- 2.47.2