Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-133999: Fixexcept parsing regression in 3.14#134035

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sobolevn merged 1 commit intopython:mainfromsobolevn:issue-133999
May 17, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
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
4 changes: 2 additions & 2 deletionsGrammar/python.gram
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1418,15 +1418,15 @@ invalid_except_stmt:
RAISE_SYNTAX_ERROR_STARTING_FROM(a, "multiple exception types must be parenthesized when using 'as'") }
| a='except' expression ['as' NAME ] NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
| a='except' NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
| 'except' expression 'as' a=expression {
| 'except' expression 'as' a=expression':' block{
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
a, "cannot use except statement with %s", _PyPegen_get_expr_name(a)) }
invalid_except_star_stmt:
| 'except' '*' a=expression ',' expressions 'as' NAME ':' {
RAISE_SYNTAX_ERROR_STARTING_FROM(a, "multiple exception types must be parenthesized when using 'as'") }
| a='except' '*' expression ['as' NAME ] NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
| a='except' '*' (NEWLINE | ':') { RAISE_SYNTAX_ERROR("expected one or more exception types") }
| 'except' '*' expression 'as' a=expression {
| 'except' '*' expression 'as' a=expression':' block{
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
a, "cannot use except* statement with %s", _PyPegen_get_expr_name(a)) }
invalid_finally_stmt:
Expand Down
17 changes: 17 additions & 0 deletionsLib/test/test_syntax.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1431,6 +1431,23 @@
Traceback (most recent call last):
SyntaxError: cannot use except* statement with literal

Regression tests for gh-133999:

>>> try: pass
... except TypeError as name: raise from None
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> try: pass
... except* TypeError as name: raise from None
Traceback (most recent call last):
SyntaxError: invalid syntax

>>> match 1:
... case 1 | 2 as abc: raise from None
Traceback (most recent call last):
SyntaxError: invalid syntax

Ensure that early = are not matched by the parser as invalid comparisons
>>> f(2, 4, x=34); 1 $ 2
Traceback (most recent call last):
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
Fix :exc:`SyntaxError` regression in :keyword:`except` parsing after
:gh:`123440`.
32 changes: 22 additions & 10 deletionsParser/parser.c
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

Loading

[8]ページ先頭

©2009-2025 Movatter.jp