Skip to content

[3.8] bpo-32892: Update the documentation for handling constants in AST. (GH-18514) #18534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down