]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38870: Extend subject of ast.unparse warnings (GH-21053)
authorBatuhan Taskaya <batuhanosmantaskaya@gmail.com>
Sun, 28 Jun 2020 01:11:43 +0000 (04:11 +0300)
committerGitHub <noreply@github.com>
Sun, 28 Jun 2020 01:11:43 +0000 (02:11 +0100)
- 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

Doc/library/ast.rst

index 6c6ad01b842c8ea9d271153ec903c174dfe051ba..25cb17811e7183e9df680f6fd2b88090ce601fcf 100644 (file)
@@ -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