Skip to content

Commit f4b8cd5

Browse files
[3.13] ast docs: Fix description of ast.Constant (GH-134741) (#134912)
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 a9ba2ec commit f4b8cd5

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
@@ -263,9 +263,9 @@ Literals
263263
.. class:: Constant(value)
264264

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

270270
.. doctest::
271271

0 commit comments

Comments
 (0)