summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew/3.10.rst
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-06-08 23:31:10 (GMT)
committerGitHub <noreply@github.com>2021-06-08 23:31:10 (GMT)
commit2ea6d890281c415e0a2f00e63526e592da8ce3d9 (patch)
tree0aff5648b72d3c7b4557408f8adfce932c59a237 /Doc/whatsnew/3.10.rst
parent3e1c7167d86a2a928cdcb659094aa10bb5550c4c (diff)
downloadcpython-2ea6d890281c415e0a2f00e63526e592da8ce3d9.zip
cpython-2ea6d890281c415e0a2f00e63526e592da8ce3d9.tar.gz
cpython-2ea6d890281c415e0a2f00e63526e592da8ce3d9.tar.bz2
bpo-43833: Emit warnings for numeric literals followed by keyword (GH-25466)
Emit a deprecation warning if the numeric literal is immediately followed by one of keywords: and, else, for, if, in, is, or. Raise a syntax error with more informative message if it is immediately followed by other keyword or identifier. Automerge-Triggered-By: GH:pablogsal
Diffstat (limited to 'Doc/whatsnew/3.10.rst')
-rw-r--r--Doc/whatsnew/3.10.rst23
1 files changed, 23 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 74e6b03..df9806a 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -1444,6 +1444,17 @@ Optimizations
Deprecated
==========
+* Currently Python accepts numeric literals immediately followed by keywords,
+ for example ``0in x``, ``1or x``, ``0if 1else 2``. It allows confusing
+ and ambigious expressions like ``[0x1for x in y]`` (which can be
+ interpreted as ``[0x1 for x in y]`` or ``[0x1f or x in y]``). Starting in
+ this release, a deprecation warning is raised if the numeric literal is
+ immediately followed by one of keywords :keyword:`and`, :keyword:`else`,
+ :keyword:`for`, :keyword:`if`, :keyword:`in`, :keyword:`is` and :keyword:`or`.
+ If future releases it will be changed to syntax warning, and finally to
+ syntax error.
+ (Contributed by Serhiy Storchaka in :issue:`43833`).
+
* Starting in this release, there will be a concerted effort to begin
cleaning up old import semantics that were kept for Python 2.7
compatibility. Specifically,
@@ -1670,6 +1681,18 @@ This section lists previously described changes and other bugfixes
that may require changes to your code.
+Changes in the Python syntax
+----------------------------
+
+* Deprecation warning is now emitted when compiling previously valid syntax
+ if the numeric literal is immediately followed by a keyword (like in ``0in x``).
+ If future releases it will be changed to syntax warning, and finally to a
+ syntax error. To get rid of the warning and make the code compatible with
+ future releases just add a space between the numeric literal and the
+ following keyword.
+ (Contributed by Serhiy Storchaka in :issue:`43833`).
+
+
Changes in the Python API
-------------------------