10000 bpo-40621: except clauses should use NAME, not target by hauntsaninja · Pull Request #20086 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-40621: except clauses should use NAME, not target #20086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test_syntax: add try-except cases that crash with the new parser
  • Loading branch information
hauntsaninja committed May 14, 2020
commit 490a79e970cae91d1383a9081186b0b809be6da5
25 changes: 25 additions & 0 deletions Lib/test/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,31 @@
...
SyntaxError: no binding for nonlocal '_A__x' found

Tests for try-except clauses:
>>> try:
... ...
... except Exception as a.b:
... pass
Traceback (most recent call last):
...
SyntaxError: invalid syntax

>>> try:
... ...
... except Exception as a[0]:
... pass
Traceback (most recent call last):
...
SyntaxError: invalid syntax

>>> try:
... ...
... except Exception as (a):
... pass
Traceback (most recent call last):
...
SyntaxError: invalid syntax


This tests assignment-context; there was a bug in Python 2.5 where compiling
a complex 'if' (one with 'elif') would fail to notice an invalid suite,
Expand Down
0