You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Fragment api changed...
sync with pysource. Simplify pysource a little
This commit is contained in:
@@ -1931,7 +1931,7 @@ def code_deparse(
|
|||||||
co,
|
co,
|
||||||
out=StringIO(),
|
out=StringIO(),
|
||||||
version=None,
|
version=None,
|
||||||
is_pypy=None,
|
is_pypy=IS_PYPY,
|
||||||
debug_opts=DEFAULT_DEBUG_OPTS,
|
debug_opts=DEFAULT_DEBUG_OPTS,
|
||||||
code_objects={},
|
code_objects={},
|
||||||
compile_mode="exec",
|
compile_mode="exec",
|
||||||
@@ -1960,9 +1960,8 @@ def code_deparse(
|
|||||||
|
|
||||||
if version is None:
|
if version is None:
|
||||||
version = sysinfo2float()
|
version = sysinfo2float()
|
||||||
if is_pypy is None:
|
|
||||||
is_pypy = IS_PYPY
|
|
||||||
|
|
||||||
|
# store final output stream for case of error
|
||||||
scanner = get_scanner(version, is_pypy=is_pypy)
|
scanner = get_scanner(version, is_pypy=is_pypy)
|
||||||
|
|
||||||
show_asm = debug_opts.get("asm", None)
|
show_asm = debug_opts.get("asm", None)
|
||||||
@@ -1989,14 +1988,17 @@ def code_deparse(
|
|||||||
is_pypy=is_pypy,
|
is_pypy=is_pypy,
|
||||||
)
|
)
|
||||||
|
|
||||||
deparsed.ast = deparsed.build_ast(tokens, customize)
|
isTopLevel = co.co_name == "<module>"
|
||||||
|
deparsed.ast = deparsed.build_ast(tokens, customize, co, isTopLevel=isTopLevel)
|
||||||
|
|
||||||
assert deparsed.ast == "stmts", "Should have parsed grammar start"
|
assert deparsed.ast == "stmts", "Should have parsed grammar start"
|
||||||
|
|
||||||
del tokens # save memory
|
# save memory
|
||||||
|
del tokens
|
||||||
|
|
||||||
# convert leading '__doc__ = "..." into doc string
|
# convert leading '__doc__ = "..." into doc string
|
||||||
assert deparsed.ast == "stmts"
|
assert deparsed.ast == "stmts"
|
||||||
|
|
||||||
(deparsed.mod_globs, nonlocals) = pysource.find_globals_and_nonlocals(
|
(deparsed.mod_globs, nonlocals) = pysource.find_globals_and_nonlocals(
|
||||||
deparsed.ast, set(), set(), co, version
|
deparsed.ast, set(), set(), co, version
|
||||||
)
|
)
|
||||||
|
@@ -135,7 +135,7 @@ import sys
|
|||||||
IS_PYPY = "__pypy__" in sys.builtin_module_names
|
IS_PYPY = "__pypy__" in sys.builtin_module_names
|
||||||
PYTHON3 = sys.version_info >= (3, 0)
|
PYTHON3 = sys.version_info >= (3, 0)
|
||||||
|
|
||||||
from xdis import iscode, COMPILER_FLAG_BIT
|
from xdis import iscode, COMPILER_FLAG_BIT, sysinfo2float
|
||||||
|
|
||||||
from uncompyle6.parser import get_python_parser
|
from uncompyle6.parser import get_python_parser
|
||||||
from uncompyle6.parsers.treenode import SyntaxTree
|
from uncompyle6.parsers.treenode import SyntaxTree
|
||||||
@@ -2564,7 +2564,7 @@ def code_deparse(
|
|||||||
assert iscode(co)
|
assert iscode(co)
|
||||||
|
|
||||||
if version is None:
|
if version is None:
|
||||||
version = float(sys.version[0:3])
|
version = sysinfo2float()
|
||||||
|
|
||||||
# store final output stream for case of error
|
# store final output stream for case of error
|
||||||
scanner = get_scanner(version, is_pypy=is_pypy)
|
scanner = get_scanner(version, is_pypy=is_pypy)
|
||||||
|
Reference in New Issue
Block a user