diff options
author | Jelle Zijlstra <jelle.zijlstra@gmail.com> | 2025-04-02 11:15:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-02 18:15:05 +0000 |
commit | 06822bfbf625e9777813542be0b8a2d10a685f30 (patch) | |
tree | 51a5b0b28121afe6e2006b4147071cb0add28f48 /Lib/_ast_unparse.py | |
parent | 643dd5107cee995c0b48511bf5dbc52c695d11af (diff) | |
download | cpython-06822bfbf625e9777813542be0b8a2d10a685f30.tar.gz cpython-06822bfbf625e9777813542be0b8a2d10a685f30.zip |
gh-118761: Fix star-import of ast (#132025)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Diffstat (limited to 'Lib/_ast_unparse.py')
-rw-r--r-- | Lib/_ast_unparse.py | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/Lib/_ast_unparse.py b/Lib/_ast_unparse.py index c03f9bd4c1d..56d9e935dd9 100644 --- a/Lib/_ast_unparse.py +++ b/Lib/_ast_unparse.py @@ -6,8 +6,6 @@ from ast import NodeVisitor from contextlib import contextmanager, nullcontext from enum import IntEnum, auto, _simple_enum -__all__ = ('unparse',) - # Large float and imaginary literals get turned into infinities in the AST. # We unparse those infinities to INFSTR. _INFSTR = "1e" + repr(sys.float_info.max_10_exp + 1) @@ -48,7 +46,7 @@ _SINGLE_QUOTES = ("'", '"') _MULTI_QUOTES = ('"""', "'''") _ALL_QUOTES = (*_SINGLE_QUOTES, *_MULTI_QUOTES) -class _Unparser(NodeVisitor): +class Unparser(NodeVisitor): """Methods in this class recursively traverse an AST and output source code for the abstract syntax; original formatting is disregarded.""" @@ -1142,9 +1140,3 @@ class _Unparser(NodeVisitor): with self.require_parens(_Precedence.BOR, node): self.set_precedence(_Precedence.BOR.next(), *node.patterns) self.interleave(lambda: self.write(" | "), self.traverse, node.patterns) - - -def unparse(ast_obj): - unparser = _Unparser() - return unparser.visit(ast_obj) -unparse.__module__ = 'ast' # backwards compatibility |