Skip to content

Commit a65bbd2

Browse files
authored
PEP 758: Small updates to PEG syntax and formatting (#4013)
1 parent 668beb0 commit a65bbd2

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

peps/pep-0758.rst

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ The decision to allow unparenthesized ``except`` blocks is based on the
7575
following considerations:
7676

7777
1. Simplicity: Removing the requirement for parentheses simplifies the syntax,
78-
making it more consistent with other parts of the language.
78+
making it more consistent with other parts of the language.
7979

8080
2. Readability: In cases where many exceptions are being caught, the removal of
81-
parentheses can improve readability by reducing visual clutter.
81+
parentheses can improve readability by reducing visual clutter.
8282

83-
3. Consistency: This change makes the ``except`` clause more consistent with other parts of Python where unambiguous, comma-separated lists don't require parentheses.
83+
3. Consistency: This change makes the ``except`` clause more consistent with
84+
other parts of Python where unambiguous, comma-separated lists don't require
85+
parentheses.
8486

8587
Specification
8688
=============
@@ -90,18 +92,12 @@ list of exception types. The grammar will be updated as follows:
9092

9193
.. code-block:: peg
9294
93-
except_block[excepthandler_ty]:
94-
| invalid_except_stmt_indent
95-
| 'except' e=expressions t=['as' z=NAME { z }] ':' b=block {
96-
_PyAST_ExceptHandler(e, (t) ? ((expr_ty) t)->v.Name.id : NULL, b, EXTRA) }
97-
| 'except' ':' b=block { _PyAST_ExceptHandler(NULL, NULL, b, EXTRA) }
98-
| invalid_except_stmt
99-
except_star_block[excepthandler_ty]:
100-
| invalid_except_star_stmt_indent
101-
| 'except' '*' e=expressions t=['as' z=NAME { z }] ':' b=block {
102-
_PyAST_ExceptHandler(e, (t) ? ((expr_ty) t)->v.Name.id : NULL, b, EXTRA) }
103-
| invalid_except_star_stmt
95+
except_block:
96+
| 'except' expressions ['as' NAME] ':' block
97+
| 'except' ':' block
10498
99+
except_star_block
100+
| 'except' '*' expressions ['as' NAME] ':' block
105101
106102
This allows both the current parenthesized syntax and the new unparenthesized
107103
syntax:

0 commit comments

Comments
 (0)