@@ -264,6 +264,49 @@ is unchanged.
264
264
Improved error messages
265
265
-----------------------
266
266
267
+ * The interpreter now provides helpful suggestions when it detects typos in Python
268
+ keywords. When a word that closely resembles a Python keyword is encountered,
269
+ the interpreter will suggest the correct keyword in the error message. This
270
+ feature helps programmers quickly identify and fix common typing mistakes. For
271
+ example:
272
+
273
+ .. code-block :: python
274
+
275
+ >> > whille True :
276
+ ... pass
277
+ Traceback (most recent call last):
278
+ File " <stdin>" , line 1
279
+ whille True :
280
+ ^^^^^^
281
+ SyntaxError : invalid syntax. Did you mean ' while' ?
282
+
283
+ >> > asynch def fetch_data ():
284
+ ... pass
285
+ Traceback (most recent call last):
286
+ File " <stdin>" , line 1
287
+ asynch def fetch_data ():
288
+ ^^^^^^
289
+ SyntaxError : invalid syntax. Did you mean ' async' ?
290
+
291
+ >> > async def foo ():
292
+ ... awaid fetch_data()
293
+ Traceback (most recent call last):
294
+ File " <stdin>" , line 2
295
+ awaid fetch_data()
296
+ ^^^^^
297
+ SyntaxError : invalid syntax. Did you mean ' await' ?
298
+
299
+ >> > raisee ValueError (" Error" )
300
+ Traceback (most recent call last):
301
+ File " <stdin>" , line 1
302
+ raisee ValueError (" Error" )
303
+ ^^^^^^
304
+ SyntaxError : invalid syntax. Did you mean ' raise' ?
305
+
306
+ While the feature focuses on the most common cases, some variations of
307
+ misspellings may still result in regular syntax errors. (Contributed by Pablo
308
+ Galindo in :gh: `132449 `.)
309
+
267
310
* When unpacking assignment fails due to incorrect number of variables, the
268
311
error message prints the received number of values in more cases than before.
269
312
(Contributed by Tushar Sadhwani in :gh: `122239 `.)
0 commit comments