Author serhiy.storchaka
Recipients BTaskaya, benjamin.peterson, brett.cannon, pablogsal, serhiy.storchaka, yselivanov
Date 2020-03-17.07:29:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1584430191.22.0.892292018718.issue39988@roundup.psfhosted.org>
In-reply-to
Content
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.

The PR depends on issue39987. See also similar issue39969.
History
Date User Action Args
2020-03-17 07:29:51serhiy.storchakasetrecipients: + serhiy.storchaka, brett.cannon, benjamin.peterson, yselivanov, pablogsal, BTaskaya
2020-03-17 07:29:51serhiy.storchakasetmessageid: <1584430191.22.0.892292018718.issue39988@roundup.psfhosted.org>
2020-03-17 07:29:51serhiy.storchakalinkissue39988 messages
2020-03-17 07:29:51serhiy.storchakacreate