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: Python crashes with new parser on invalid exception handlers
Type: Stage: resolved
Components: Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder: PEG Parser: Invalid targets for augassign and except succeed
View: 40618
Assigned To: Nosy List: hauntsaninja, pablogsal
Priority: normal Keywords: patch

Created on 2020-05-14 07:40 by hauntsaninja, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 20086 closed hauntsaninja, 2020-05-14 07:41
Messages (2)
msg368818 - (view) Author: Shantanu (hauntsaninja) * Date: 2020-05-14 07:40
```
~/dev/cpython master λ ./python.exe --version --version                                           
Python 3.9.0a6+ (heads/master:a15c9b3a05, May 14 2020, 00:31:47) 
[Clang 11.0.0 (clang-1100.0.33.17)]



# should raise a syntax error, instead crashes
~/dev/cpython master λ cat test.py 
try:
    1 / 0
except Exception as a.b:
    pass
~/dev/cpython master λ ./python.exe test.py            
[1]    63986 bus error  ./python.exe test.py
~/dev/cpython master λ ./python.exe -Xoldparser test.py
  File "/Users/shantanu/dev/cpython/test.py", line 3
    except Exception as a.b:
                         ^
SyntaxError: invalid syntax



# should raise a syntax error, instead passes
~/dev/cpython master λ cat test2.py
try:
    1 / 0
except Exception as (a):
    pass
~/dev/cpython master λ ./python.exe test2.py
~/dev/cpython master λ ./python.exe -Xoldparser test2.py
  File "/Users/shantanu/dev/cpython/test2.py", line 3
    except Exception as (a):
                        ^
SyntaxError: invalid syntax



# should raise a syntax error, instead crashes
~/dev/cpython master λ cat test3.py
try:
    1 / 0
except Exception as a[0]:
    pass
~/dev/cpython master λ ./python.exe test3.py
[1]    64206 bus error  ./python.exe test3.py
~/dev/cpython master λ ./python.exe -Xoldparser test3.py
  File "/Users/shantanu/dev/cpython/test3.py", line 3
    except Exception as a[0]:
                         ^
SyntaxError: invalid syntax
```

The old grammar expects a NAME here, but the new grammar attempts to use a target (https://docs.python.org/3/reference/grammar.html). Seems like we should just go back to using NAME.
msg368825 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-05-14 11:08
Thanks for the issue and the PR @hauntsaninja. Unfortunately, I think this is already covered by #20083 and https://bugs.python.org/issue40618
History
Date User Action Args
2022-04-11 14:59:31adminsetgithub: 84801
2020-05-14 20:13:22pablogsalsetstatus: open -> closed
resolution: duplicate
superseder: PEG Parser: Invalid targets for augassign and except succeed
stage: patch review -> resolved
2020-05-14 11:08:14pablogsalsetnosy: + pablogsal
messages: + msg368825
2020-05-14 07:41:28hauntsaninjasetkeywords: + patch
stage: patch review
pull_requests: + pull_request19390
2020-05-14 07:40:23hauntsaninjacreate