This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: PEG Parser: Invalid targets for augassign and except succeed
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: lys.nikolaou Nosy List: gvanrossum, lys.nikolaou, pablogsal
Priority: normal Keywords: patch

Created on 2020-05-14 00:15 by lys.nikolaou, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 20083 merged lys.nikolaou, 2020-05-14 00:22
Messages (2)
msg368809 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-05-14 00:15
Tuples and lists, which are invalid augmented assignment targets, currently get successfully parsed, without failing.

➜  cpython git:(targets-fix) ✗ ./python -X oldparser              
Python 3.9.0a6+ (heads/master-dirty:75cd8e48c6, May 14 2020, 03:01:42) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> (a, b) += (1, 2)
  File "<stdin>", line 1
SyntaxError: illegal expression for augmented assignment


➜  cpython git:(pr/20076) ./python             
Python 3.9.0a6+ (heads/pr/20076:bcf5be2772, May 14 2020, 02:15:37) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> (a, b) += 1
SystemError: invalid node type (26) for augmented assignment

We also accept arbitrary targets in `except` clauses, while we should only be accepting NAME nodes:

➜  cpython git:(master) ./python 
Python 3.9.0a6+ (heads/master:75cd8e48c6, May 14 2020, 03:14:03) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
...     pass
... except Exception as a.b:
...     pass
... 
[1]    135956 segmentation fault (core dumped)  ./python
msg368866 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-05-14 20:13
New changeset ce21cfca7bb2d18921bc4ac27cb064726996c519 by Lysandros Nikolaou in branch 'master':
bpo-40618: Disallow invalid targets in augassign and except clauses (GH-20083)
https://github.com/python/cpython/commit/ce21cfca7bb2d18921bc4ac27cb064726996c519
History
Date User Action Args
2022-04-11 14:59:31adminsetgithub: 84798
2020-05-14 22:54:13lys.nikolaousetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-05-14 20:13:54pablogsalsetmessages: + msg368866
2020-05-14 20:13:22pablogsallinkissue40621 superseder
2020-05-14 18:31:15gvanrossumlinkissue40627 superseder
2020-05-14 00:22:39lys.nikolaousetkeywords: + patch
stage: patch review
pull_requests: + pull_request19387
2020-05-14 00:15:04lys.nikolaoucreate