File tree Expand file tree Collapse file tree 2 files changed +17
-13
lines changed
Misc/NEWS.d/next/Core_and_Builtins Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,22 @@ Improved error messages
174174 ^^^^^^^
175175 ValueError: too many values to unpack (expected 3, got 4)
176176
177+ * `elif ` statements that follow an `else ` block now have a specific error message.
178+ (Contributed by Steele Farnsworth in :gh: `129902 `.)
179+
180+ .. code-block :: pycon
181+
182+ >>> if who == "me":
183+ ... print("It's me!")
184+ ... else:
185+ ... print("It's not me!")
186+ ... elif who is None:
187+ ... print("Who is it?")
188+ File "<stdin>", line 5
189+ elif who is None:
190+ ^^^^
191+ SyntaxError: 'elif' block follows an 'else' block
192+
177193
178194 .. _whatsnew314-pep741 :
179195
Original file line number Diff line number Diff line change 1- `elif ` statements that follow an `else ` block now have a specific error message.
2- ```py
3- >>> if who == "me":
4- ... print("It's me!")
5- ... else:
6- ... print("It's not me!")
7- ... elif who is None:
8- ... print("Who is it?")
9- File "<stdin>", line 5
10- elif who is None:
11- ^^^^
12- SyntaxError: 'elif' block follows an 'else' block
13- ` ``
1+ `elif ` statements that follow an `else ` block now have a specific error message.
You can’t perform that action at this time.
0 commit comments