[Python-checkins] [3.9] bpo-42086: Document AST operator nodes acts as a singleton (GH-22896) (GH-22897)

miss-islington webhook-mailer at python.org
Fri Nov 13 04:05:45 EST 2020


https://github.com/python/cpython/commit/bc777047833256bc6b10b2c7b46cce9e9e6f956c
commit: bc777047833256bc6b10b2c7b46cce9e9e6f956c
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2020-11-13T01:05:41-08:00
summary:

[3.9] bpo-42086: Document AST operator nodes acts as a singleton (GH-22896) (GH-22897)



Automerge-Triggered-By: GH:gvanrossum
(cherry picked from commit b37c994e5ac73268abe23c52005b80cdca099793)


Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya at gmail.com>

files:
M Doc/library/ast.rst

diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index 932f7258f9dcd..95cb017d145ca 100644
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -1503,6 +1503,13 @@ Async and await
    fields as :class:`For` and :class:`With`, respectively. Only valid in the
    body of an :class:`AsyncFunctionDef`.
 
+.. note::
+   When a string is parsed by :func:`ast.parse`, operator nodes (subclasses
+   of :class:`ast.operator`, :class:`ast.unaryop`, :class:`ast.cmpop`,
+   :class:`ast.boolop` and :class:`ast.expr_context`) on the returned tree
+   will be singletons. Changes to one will be reflected in all other
+   occurrences of the same value (e.g. :class:`ast.Add`).
+
 
 :mod:`ast` Helpers
 ------------------



More information about the Python-checkins mailing list