New submission from Robert Jordens: According to the documentation the "exec a in b, c" is equivalent to "exec(a, b, c)". But in the testcase below the tuple form causes a SyntaxError while the statement form works fine.
diff -r e770d8c4291c Lib/test/test_compile.py --- a/Lib/test/test_compile.py Tue May 27 03:30:44 2014 -0400 +++ b/Lib/test/test_compile.py Wed May 28 02:45:31 2014 -0600 @@ -90,6 +90,22 @@ with self.assertRaises(TypeError): exec("a = b + 1", g, l) in g, l + def test_nested_qualified_exec(self): + # Can use qualified exec in nested functions. + code = [""" +def g(): + def f(): + if True: + exec "" in {}, {} + """, """ +def g(): + def f(): + if True: + exec("", {}, {}) + """] + for c in code: + compile(c, "<code>", "exec") + def test_exec_with_general_mapping_for_locals(self): class M: SyntaxError: unqualified exec is not allowed in function 'f' it is a nested function (<code>, line 5) ---------- components: Interpreter Core messages: 219259 nosy: Robert.Jordens priority: normal severity: normal status: open title: "exec(a, b, c)" not the same as "exec a in b, c" in nested functions type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21591> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com