You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Better simpler fragment fix...
remove hide_internal test. We changed the default and that's what whas causing RETURN_LAST to not get included.
This commit is contained in:
@@ -68,11 +68,6 @@ class Python3Parser(PythonParser):
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
||||
JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
|
||||
# FIXME: This is used only in the fragment parser
|
||||
# Fix the fragment parser so that it adds RETURN_LAST
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
||||
JUMP_BACK RETURN_VALUE
|
||||
|
||||
set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter
|
||||
COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
|
||||
@@ -346,10 +341,6 @@ class Python3Parser(PythonParser):
|
||||
stmt ::= return_closure
|
||||
return_closure ::= LOAD_CLOSURE RETURN_VALUE RETURN_LAST
|
||||
|
||||
# FIXME: This is used only in the fragment parser
|
||||
# Fix the fragment parser so that it adds RETURN_LAST
|
||||
return_closure ::= LOAD_CLOSURE RETURN_VALUE
|
||||
|
||||
stmt ::= whileTruestmt
|
||||
ifelsestmt ::= testexpr c_stmts_opt JUMP_FORWARD else_suite _come_froms
|
||||
"""
|
||||
|
@@ -969,7 +969,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
if node[0] == "LOAD_LISTCOMP":
|
||||
start = len(self.f.getvalue())
|
||||
self.set_pos_info(node[0], start - 1, start)
|
||||
self.comprehension_walk3(node, 1, 0)
|
||||
self.comprehension_walk_newer(node, 1, 0)
|
||||
self.write("]")
|
||||
self.prune()
|
||||
|
||||
@@ -1163,7 +1163,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
self.p.insts = self.scanner.insts
|
||||
ast = python_parser.parse(self.p, tokens, customize)
|
||||
self.p.insts = p_insts
|
||||
except (parser.ParserError, AssertionError) as e:
|
||||
except (python_parser.ParserError, AssertionError) as e:
|
||||
raise ParserError(e, tokens)
|
||||
maybe_show_tree(self, ast)
|
||||
return ast
|
||||
@@ -1178,20 +1178,19 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
#
|
||||
# NOTE: this differs from behavior in pysource.py
|
||||
|
||||
if self.hide_internal:
|
||||
if len(tokens) >= 2 and not noneInNames:
|
||||
if tokens[-1].kind in ("RETURN_VALUE", "RETURN_VALUE_LAMBDA"):
|
||||
# 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:
|
||||
del tokens[-2:]
|
||||
else:
|
||||
tokens.append(Token("RETURN_LAST"))
|
||||
if len(tokens) >= 2 and not noneInNames:
|
||||
if tokens[-1].kind in ("RETURN_VALUE", "RETURN_VALUE_LAMBDA"):
|
||||
# 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:
|
||||
del tokens[-2:]
|
||||
else:
|
||||
tokens.append(Token("RETURN_LAST"))
|
||||
if len(tokens) == 0:
|
||||
return PASS
|
||||
else:
|
||||
tokens.append(Token("RETURN_LAST"))
|
||||
if len(tokens) == 0:
|
||||
return PASS
|
||||
|
||||
# Build parse tree from tokenized and massaged disassembly.
|
||||
try:
|
||||
|
Reference in New Issue
Block a user