This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rjordens
Recipients rjordens
Date 2014-05-28.08:47:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1401266879.61.0.867969486588.issue21591@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2014-05-28 08:47:59rjordenssetrecipients: + rjordens
2014-05-28 08:47:59rjordenssetmessageid: <1401266879.61.0.867969486588.issue21591@psf.upfronthosting.co.za>
2014-05-28 08:47:59rjordenslinkissue21591 messages
2014-05-28 08:47:57rjordenscreate