main
main copied to clipboard
We are not catching SyntaxError: unqualified exec is not allowed in function 'xxx' it is a nested function
Notice this when trying one of our existing tests. (I attached it in case the file changed). Sorry for no simpler repro.
D:\merlin2\Main\Languages\IronPython\Tests > cpy test_methoddispatch.py
File "test_methoddispatch.py", line 909
exec line
SyntaxError: unqualified exec is not allowed in function 'testfunctionhelper'
it is a nested function
D:\merlin2\Main\Languages\IronPython\Tests > ipyd test_methoddispatch.py
testing test_array_badargs
testing test_array_error_message
testing test_default_value
testing test_enum
testing test_explicit
testing test_function
testing test_io_memorystream
testing test_max_args
testing test_missing_value
Work Item Details
Original CodePlex Issue: Issue 23928 Status: Active Reason Closed: Unassigned Assigned to: Unassigned Reported on: Jul 28, 2009 at 12:11 AM Reported by: dfugate Updated on: Feb 22, 2013 at 2:12 AM Updated by: jdhardy Custom value: Reported internally at Microsoft. CreatedDate: 1/18/2008 NewInternalID: 409749 OldInternalID: 369214 AreaPath: IronPython\Compiler\Parser
Here's repro code:
def a():
def b():
exec('print("A")')
return None
Under CPython 2.7 it fails with:
SyntaxError: unqualified exec is not allowed in function 'b' because it is a nested function
Here's a variation:
def a():
def b():
return None
exec('print("A")')
This one fails (under CPython 2.7) with:
SyntaxError: unqualified exec is not allowed in function 'a' because it contains a nested function with free variables
Both appear to be acceptable with CPython 3.5 or IronPython. My question is then, does IronPython work properly? I assume CPython 2.7 has those restrictions for a reason...