]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] bpo-42086: Document AST operator nodes acts as a singleton (GH-22896) (GH-22897)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 13 Nov 2020 09:05:41 +0000 (01:05 -0800)
committerGitHub <noreply@github.com>
Fri, 13 Nov 2020 09:05:41 +0000 (01:05 -0800)
Automerge-Triggered-By: GH:gvanrossum
(cherry picked from commit b37c994e5ac73268abe23c52005b80cdca099793)

Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>
Doc/library/ast.rst

index 932f7258f9dcddba68add1384004b8b8742050dd..95cb017d145ca8f3e17c658daffd02250c2767ba 100644 (file)
@@ -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
 ------------------