Skip to content

Commit 3e256b9

Browse files
authored
gh-123539: Add new error message changes to "Whats New" (#133344)
1 parent 881144f commit 3e256b9

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,36 @@ Improved error messages
479479
Traceback (most recent call last):
480480
SyntaxError: invalid syntax. Is this intended to be part of the string?
481481
482+
* When strings have incompatible prefixes, the error now shows
483+
which prefixes are incompatible. (Contributed by
484+
Nikita Sobolev in :gh:`133197`.)
485+
486+
.. code-block:: pycon
487+
488+
>>> ub'abc'
489+
File "<python-input-0>", line 1
490+
ub'abc'
491+
^^
492+
SyntaxError: 'u' and 'b' prefixes are incompatible
493+
494+
* Improved error messages when using ``as`` with incompatible targets in:
495+
496+
- Imports: ``import ... as ...``
497+
- From imports: ``from ... import ... as ...``
498+
- Except handlers: ``except ... as ...``
499+
- Pattern-match cases: ``case ... as ...``
500+
501+
(Contributed by Nikita Sobolev in :gh:`123539`,
502+
:gh:`123562`, and :gh:`123440`.)
503+
504+
.. code-block:: pycon
505+
506+
>>> import ast as arr[0]
507+
File "<python-input-1>", line 1
508+
import ast as arr[0]
509+
^^^^^^
510+
SyntaxError: cannot use subscript as import target
511+
482512
483513
.. _whatsnew314-pep741:
484514

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy