Skip to content

Commit 4927596

Browse files
[3.14] ast docs: Fix description of ast.Constant (GH-134741) (#134911)
Contrary to the current docs, ast.Constant will never hold containers such as frozenset or tuple; the Python parser only emits it for simple literals. For precision, add the exact list of types that may be contained in an ast.Constant. (cherry picked from commit 381020d) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent 9c2e0fe commit 4927596

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Doc/library/ast.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ Literals
268268
.. class:: Constant(value)
269269

270270
A constant value. The ``value`` attribute of the ``Constant`` literal contains the
271-
Python object it represents. The values represented can be simple types
272-
such as a number, string or ``None``, but also immutable container types
273-
(tuples and frozensets) if all of their elements are constant.
271+
Python object it represents. The values represented can be instances of :class:`str`,
272+
:class:`bytes`, :class:`int`, :class:`float`, :class:`complex`, and :class:`bool`,
273+
and the constants :data:`None` and :data:`Ellipsis`.
274274

275275
.. doctest::
276276

0 commit comments

Comments
 (0)