mirror of
https://github.com/python/cpython.git
synced 2025-09-04 16:01:10 +00:00
gh-131831: Implement PEP 758 – Allow except and except* expressions without parentheses (#131833)
This commit is contained in:
parent
053c285f6b
commit
c2ac662f28
7 changed files with 381 additions and 270 deletions
|
@ -1667,28 +1667,14 @@ Make sure that the old "raise X, Y[, Z]" form is gone:
|
|||
SyntaxError: invalid syntax
|
||||
|
||||
Check that an multiple exception types with missing parentheses
|
||||
raise a custom exception
|
||||
|
||||
>>> try:
|
||||
... pass
|
||||
... except A, B:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: multiple exception types must be parenthesized
|
||||
|
||||
>>> try:
|
||||
... pass
|
||||
... except A, B, C:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: multiple exception types must be parenthesized
|
||||
raise a custom exception only when using 'as'
|
||||
|
||||
>>> try:
|
||||
... pass
|
||||
... except A, B, C as blech:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: multiple exception types must be parenthesized
|
||||
SyntaxError: multiple exception types must be parenthesized when using 'as'
|
||||
|
||||
>>> try:
|
||||
... pass
|
||||
|
@ -1697,29 +1683,15 @@ raise a custom exception
|
|||
... finally:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: multiple exception types must be parenthesized
|
||||
SyntaxError: multiple exception types must be parenthesized when using 'as'
|
||||
|
||||
|
||||
>>> try:
|
||||
... pass
|
||||
... except* A, B:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: multiple exception types must be parenthesized
|
||||
|
||||
>>> try:
|
||||
... pass
|
||||
... except* A, B, C:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: multiple exception types must be parenthesized
|
||||
|
||||
>>> try:
|
||||
... pass
|
||||
... except* A, B, C as blech:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: multiple exception types must be parenthesized
|
||||
SyntaxError: multiple exception types must be parenthesized when using 'as'
|
||||
|
||||
>>> try:
|
||||
... pass
|
||||
|
@ -1728,7 +1700,7 @@ raise a custom exception
|
|||
... finally:
|
||||
... pass
|
||||
Traceback (most recent call last):
|
||||
SyntaxError: multiple exception types must be parenthesized
|
||||
SyntaxError: multiple exception types must be parenthesized when using 'as'
|
||||
|
||||
Custom exception for 'except*' without an exception type
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue