[Python-checkins] bpo-32892: Update the documentation for handling constants in AST. (GH-18514)
Miss Islington (bot)
webhook-mailer at python.org
Mon Feb 17 04:09:54 EST 2020
https://github.com/python/cpython/commit/988aeba94bf1dab81dd52fc7b02dca7a57ea8ba0
commit: 988aeba94bf1dab81dd52fc7b02dca7a57ea8ba0
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-02-17T01:09:49-08:00
summary:
bpo-32892: Update the documentation for handling constants in AST. (GH-18514)
(cherry picked from commit 85a2eef473a2c9ed3ab9c6ee339891fe99adbbc9)
Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>
files:
M Doc/library/ast.rst
M Doc/whatsnew/3.8.rst
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index a5dd0e1cc70dd..80afbbce4167e 100644
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -101,12 +101,16 @@ Node classes
node = ast.UnaryOp(ast.USub(), ast.Constant(5, lineno=0, col_offset=0),
lineno=0, col_offset=0)
+.. versionchanged:: 3.8
+
+ Class :class:`ast.Constant` is now used for all constants.
+
.. deprecated:: 3.8
- Class :class:`ast.Constant` is now used for all constants. Old classes
- :class:`ast.Num`, :class:`ast.Str`, :class:`ast.Bytes`,
+ Old classes :class:`ast.Num`, :class:`ast.Str`, :class:`ast.Bytes`,
:class:`ast.NameConstant` and :class:`ast.Ellipsis` are still available,
- but they will be removed in future Python releases.
+ but they will be removed in future Python releases. In the meanwhile,
+ instantiating them will return an instance of a different class.
.. _abstract-grammar:
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 9b61e1f05542d..3ef97c98ca907 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -1942,6 +1942,12 @@ Changes in the Python API
:exc:`dbm.gnu.error` or :exc:`dbm.ndbm.error`) instead of :exc:`KeyError`.
(Contributed by Xiang Zhang in :issue:`33106`.)
+* Simplified AST for literals. All constants will be represented as
+ :class:`ast.Constant` instances. Instantiating old classes ``Num``,
+ ``Str``, ``Bytes``, ``NameConstant`` and ``Ellipsis`` will return
+ an instance of ``Constant``.
+ (Contributed by Serhiy Storchaka in :issue:`32892`.)
+
* :func:`~os.path.expanduser` on Windows now prefers the :envvar:`USERPROFILE`
environment variable and does not use :envvar:`HOME`, which is not normally
set for regular user accounts.
More information about the Python-checkins
mailing list