You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.