New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:

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.

----------
components: Interpreter Core
messages: 364390
nosy: BTaskaya, benjamin.peterson, brett.cannon, pablogsal, serhiy.storchaka, 
yselivanov
priority: normal
severity: normal
status: open
title: Remove AugLoad and AugStore expression context from AST
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39988>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to