Skip to content

Commit 6e39999

Browse files
authored
[3.9] bpo-38870: Extend subject of ast.unparse warnings (GH-21053) (GH-21191)
- Mention that some compiler optimizations might not roundtrip exactly (such as constant tuples and frozensets). - Add a warning about it might raise RecursionError on very complex expressions due to the recursive unparsing aspect of ast.unparse (cherry picked from commit 8df1016)
1 parent 6803ff2 commit 6e39999

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Doc/library/ast.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,12 @@ and classes for traversing abstract syntax trees:
15531553

15541554
.. warning::
15551555
The produced code string will not necessarily be equal to the original
1556-
code that generated the :class:`ast.AST` object.
1556+
code that generated the :class:`ast.AST` object (without any compiler
1557+
optimizations, such as constant tuples/frozensets).
1558+
1559+
.. warning::
1560+
Trying to unparse a highly complex expression would result with
1561+
:exc:`RecursionError`.
15571562

15581563
.. versionadded:: 3.9
15591564

0 commit comments

Comments
 (0)