You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Some small variable-name changes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2018 by Rocky Bernstein
|
||||
# Copyright (c) 2018, 2022 by Rocky Bernstein
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -141,8 +141,8 @@ def code_deparse_align(co, out=sys.stderr, version=None, is_pypy=None,
|
||||
debug_parser=debug_parser, compile_mode=compile_mode,
|
||||
is_pypy = is_pypy)
|
||||
|
||||
isTopLevel = co.co_name == '<module>'
|
||||
deparsed.ast = deparsed.build_ast(tokens, customize, co, isTopLevel=isTopLevel)
|
||||
is_top_level_module = co.co_name == '<module>'
|
||||
deparsed.ast = deparsed.build_ast(tokens, customize, co, is_top_level_module=is_top_level_module)
|
||||
|
||||
assert deparsed.ast == 'stmts', 'Should have parsed grammar start'
|
||||
|
||||
|
@@ -1148,7 +1148,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
code,
|
||||
is_lambda=False,
|
||||
noneInNames=False,
|
||||
isTopLevel=False,
|
||||
is_top_level_module=False,
|
||||
):
|
||||
|
||||
# FIXME: DRY with pysource.py
|
||||
@@ -1190,7 +1190,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
# Python 3.4's classes can add a "return None" which is
|
||||
# invalid syntax.
|
||||
if tokens[-2].kind == "LOAD_CONST":
|
||||
if isTopLevel or tokens[-2].pattr is None:
|
||||
if is_top_level_module or tokens[-2].pattr is None:
|
||||
del tokens[-2:]
|
||||
else:
|
||||
tokens.append(Token("RETURN_LAST"))
|
||||
@@ -2065,8 +2065,8 @@ def code_deparse(
|
||||
is_pypy=is_pypy,
|
||||
)
|
||||
|
||||
isTopLevel = co.co_name == "<module>"
|
||||
deparsed.ast = deparsed.build_ast(tokens, customize, co, isTopLevel=isTopLevel)
|
||||
is_top_level_module = co.co_name == "<module>"
|
||||
deparsed.ast = deparsed.build_ast(tokens, customize, co, is_top_level_module=is_top_level_module)
|
||||
|
||||
assert deparsed.ast == "stmts", "Should have parsed grammar start"
|
||||
|
||||
|
@@ -2564,7 +2564,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
code,
|
||||
is_lambda=False,
|
||||
noneInNames=False,
|
||||
isTopLevel=False,
|
||||
is_top_level_module=False,
|
||||
):
|
||||
|
||||
# FIXME: DRY with fragments.py
|
||||
@@ -2590,10 +2590,10 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
|
||||
except (python_parser.ParserError, AssertionError) as e:
|
||||
raise ParserError(e, tokens, self.p.debug["reduce"])
|
||||
transform_ast = self.treeTransform.transform(ast, code)
|
||||
transform_tree = self.treeTransform.transform(ast, code)
|
||||
self.maybe_show_tree(ast, phase="after")
|
||||
del ast # Save memory
|
||||
return transform_ast
|
||||
return transform_tree
|
||||
|
||||
# The bytecode for the end of the main routine has a
|
||||
# "return None". However you can't issue a "return" statement in
|
||||
@@ -2605,7 +2605,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
# Python 3.4's classes can add a "return None" which is
|
||||
# invalid syntax.
|
||||
if tokens[-2].kind == "LOAD_CONST":
|
||||
if isTopLevel or tokens[-2].pattr is None:
|
||||
if is_top_level_module or tokens[-2].pattr is None:
|
||||
del tokens[-2:]
|
||||
else:
|
||||
tokens.append(Token("RETURN_LAST"))
|
||||
@@ -2630,12 +2630,12 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
checker(ast, False, self.ast_errors)
|
||||
|
||||
self.customize(customize)
|
||||
transform_ast = self.treeTransform.transform(ast, code)
|
||||
transform_tree = self.treeTransform.transform(ast, code)
|
||||
|
||||
self.maybe_show_tree(ast, phase="before")
|
||||
|
||||
del ast # Save memory
|
||||
return transform_ast
|
||||
return transform_tree
|
||||
|
||||
@classmethod
|
||||
def _get_mapping(cls, node):
|
||||
@@ -2684,7 +2684,7 @@ def code_deparse(
|
||||
linestarts=linestarts,
|
||||
)
|
||||
|
||||
isTopLevel = co.co_name == "<module>"
|
||||
is_top_level_module = co.co_name == "<module>"
|
||||
if compile_mode == "eval":
|
||||
deparsed.hide_internal = False
|
||||
deparsed.compile_mode = compile_mode
|
||||
@@ -2693,7 +2693,7 @@ def code_deparse(
|
||||
customize,
|
||||
co,
|
||||
is_lambda=(compile_mode == "lambda"),
|
||||
isTopLevel=isTopLevel,
|
||||
is_top_level_module=is_top_level_module,
|
||||
)
|
||||
|
||||
#### XXX workaround for profiling
|
||||
|
Reference in New Issue
Block a user