Author: Antonio Cuni <[email protected]>
Branch:
Changeset: r76436:9159bcc2b0d0
Date: 2015-03-17 17:20 +0100
http://bitbucket.org/pypy/pypy/changeset/9159bcc2b0d0/
Log: fix issue #2000, which was caused by 2e4e36c84077: partially revert
it, by keeping the AST transformation but also allow the possibility
to pass a tuple to it
diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1619,6 +1619,13 @@
def prepare_exec(f, prog, globals, locals, compile_flags, builtin,
codetype):
"""Manipulate parameters to exec statement to (codeobject, dict, dict).
"""
+ if (globals is None and locals is None and
+ isinstance(prog, tuple) and
+ (len(prog) == 2 or len(prog) == 3)):
+ globals = prog[1]
+ if len(prog) == 3:
+ locals = prog[2]
+ prog = prog[0]
if globals is None:
globals = f.f_globals
if locals is None:
diff --git a/pypy/interpreter/test/test_exec.py
b/pypy/interpreter/test/test_exec.py
--- a/pypy/interpreter/test/test_exec.py
+++ b/pypy/interpreter/test/test_exec.py
@@ -262,3 +262,11 @@
"""]
for c in code:
compile(c, "<code>", "exec")
+
+ def test_exec_tuple(self):
+ # note: this is VERY different than testing exec("a = 42", d), because
+ # this specific case is handled specially by the AST compiler
+ d = {}
+ x = ("a = 42", d)
+ exec x
+ assert d['a'] == 42
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit