-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Remove AugLoad and AugStore expression context from AST #84169
Comments
AugLoad and AugStore are never exposed to the user. They are not generated by the parser and the compiler does not accept it. >>> from ast import *
>>> tree = Module(body=[AugAssign(target=Name(id='x', ctx=AugStore()), op=Add(), value=Constant(value=1))], type_ignores=[])
>>> compile(fix_missing_locations(tree), 'sample', 'exec')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: expression must have Store context but has AugStore instead They are only used in temporary nodes created by the compiler. But the support of AugLoad and AugStore is spread across many sites in the compiler, adding special cases which have very little in common with the "normal" cases of Load, Store and Del. The proposed PR removes AugLoad and AugStore. It moves support of the augmented assignment into a separate function and cleans up the rest of the code. This saves around 70 lines of handwritten code and around 60 lines of generated code. |
It is possible also to get rid of the ctx argument at all. The context may be determined by the parent nodes. But it is larger and breaking change, so I'll open a separate issue for it. |
This change may have broken pyflakes on nightly Python. Is that expected or problematic? Error message:
Seen at: https://travis-ci.org/github/buildinspace/peru/jobs/665005023 |
Ah never mind, it looks like that's covered by https://bugs.python.org/issue39999 |
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: