New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python 3.5 can't compile AST involving PEP 448 unpacking #69163
Comments
The compile() function is not able to compile an AST created from code that uses some of the new unpacking generalizations in PEP-448. Example: code = '''
a = { 'x':1, 'y':2 }
b = { **a, 'z': 3 }
'''
# Works
ccode = compile(code, '', 'exec')
# Crashes
import ast
tree = ast.parse(code)
ccode = compile(tree, '', 'exec') # ---------------------------------- Error Traceback: Traceback (most recent call last):
File "bug.py", line 11, in <module>
ccode = compile(tree, '', 'exec')
ValueError: None disallowed in expression list Note: This bug makes it impossible to try generalized unpacking examples interactively in IPython. |
Good find, David. Thanks! Please review the attached patch. |
Good catch! Please file a pull request via bitbucket. |
Patch looks good to me. I was initially going to query the changes to the break/continue AST tests, but then realised they were needed to avoid a compile error for break/continue outside a loop now that we ensure the resulting AST can be used to generate code. |
Do we not have a test that compiles the entire stdlib using the ast module? We used to have one for the old compiler package. If don't have such a test we should probably add it even if it requires a -u option. |
Larry, I created a PR for you: https://bitbucket.org/larry/cpython350/pull-requests/10/issue-24975-fix-ast-compilation-for-pep/diff Brett, Should we do that in a separate issue targeting 3.6 only? |
Created issue bpo-24981 to track the test case idea. |
Merged. Please forward-merge to 3.5.1 and 3.6, thanks! |
New changeset e9df8543d7bc by Yury Selivanov in branch '3.5': New changeset ea79be5b201e by Yury Selivanov in branch '3.5': New changeset 1dcd7f257ed8 by Yury Selivanov in branch 'default': |
Thanks Nick and Larry for code reviews and merge! |
Upon writing a proof-of-concept file for bpo-24981, I discovered an stdlib file that gave the same error. C:/programs/Python35/Lib\distutils/_msvccompiler.py I presume the applied fix will apply to this also. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: