]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-32892: Update the documentation for handling constants in AST. (GH-18514)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 17 Feb 2020 09:03:00 +0000 (11:03 +0200)
committerGitHub <noreply@github.com>
Mon, 17 Feb 2020 09:03:00 +0000 (11:03 +0200)
Doc/library/ast.rst
Doc/whatsnew/3.8.rst

index 2cee8738e5834ceb6eac919096d6d7f7f21dcef0..bfd571deb4fd1f3f2441614048187575f532d0ae 100644 (file)
@@ -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:
index cb4c518662d6baae75d0f42113387b2bb5ecf420..09047c460df01c9ec3d74b3ab512e3bbe7753f2a 100644 (file)
@@ -1940,6 +1940,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.