]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
simplify tornado.util.exec_in 1776/head
authorAndrey Sumin <an.sumin@hh.ru>
Thu, 21 Jul 2016 13:11:06 +0000 (16:11 +0300)
committerAndrey Sumin <an.sumin@hh.ru>
Thu, 21 Jul 2016 13:11:06 +0000 (16:11 +0300)
tornado/util.py

index 53584f98b4282900ab8363d7cb033f5f84bed3f3..28e74e7dc0e3be3563b5868f34bcdc294be45b50 100644 (file)
@@ -165,30 +165,22 @@ def raise_exc_info(exc_info):
 
 def exec_in(code, glob, loc=None):
     # type: (Any, Dict[str, Any], Optional[Mapping[str, Any]]) -> Any
-    pass
+    if isinstance(code, basestring_type):
+        # exec(string) inherits the caller's future imports; compile
+        # the string first to prevent that.
+        code = compile(code, '<string>', 'exec', dont_inherit=True)
+    exec(code, glob, loc)
 
 
 if PY3:
     exec("""
 def raise_exc_info(exc_info):
     raise exc_info[1].with_traceback(exc_info[2])
-
-def exec_in(code, glob, loc=None):
-    if isinstance(code, str):
-        code = compile(code, '<string>', 'exec', dont_inherit=True)
-    exec(code, glob, loc)
 """)
 else:
     exec("""
 def raise_exc_info(exc_info):
     raise exc_info[0], exc_info[1], exc_info[2]
-
-def exec_in(code, glob, loc=None):
-    if isinstance(code, basestring):
-        # exec(string) inherits the caller's future imports; compile
-        # the string first to prevent that.
-        code = compile(code, '<string>', 'exec', dont_inherit=True)
-    exec code in glob, loc
 """)