[Python-checkins] bpo-38870: Extend subject of ast.unparse warnings (GH-21053)
Batuhan Taskaya
webhook-mailer at python.org
Sat Jun 27 21:11:47 EDT 2020
https://github.com/python/cpython/commit/8df1016e2ef8c0a9f4d15bf7894c284295c99d9f
commit: 8df1016e2ef8c0a9f4d15bf7894c284295c99d9f
branch: master
author: Batuhan Taskaya <batuhanosmantaskaya at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-06-28T02:11:43+01:00
summary:
bpo-38870: Extend subject of ast.unparse warnings (GH-21053)
- 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 recursive unparsing aspect of ast.unparse
files:
M Doc/library/ast.rst
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index 6c6ad01b842c8..25cb17811e718 100644
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -1553,7 +1553,12 @@ and classes for traversing abstract syntax trees:
.. warning::
The produced code string will not necessarily be equal to the original
- code that generated the :class:`ast.AST` object.
+ code that generated the :class:`ast.AST` object (without any compiler
+ optimizations, such as constant tuples/frozensets).
+
+ .. warning::
+ Trying to unparse a highly complex expression would result with
+ :exc:`RecursionError`.
.. versionadded:: 3.9
More information about the Python-checkins
mailing list