You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Bug in Python 3.x genexpr
This commit is contained in:
@@ -102,9 +102,6 @@ class PythonParser(GenericASTBuilder):
|
|||||||
def p_genexpr(self, args):
|
def p_genexpr(self, args):
|
||||||
'''
|
'''
|
||||||
expr ::= genexpr
|
expr ::= genexpr
|
||||||
|
|
||||||
genexpr ::= LOAD_GENEXPR MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1
|
|
||||||
|
|
||||||
stmt ::= genexpr_func
|
stmt ::= genexpr_func
|
||||||
|
|
||||||
genexpr_func ::= LOAD_FAST FOR_ITER designator comp_iter JUMP_BACK
|
genexpr_func ::= LOAD_FAST FOR_ITER designator comp_iter JUMP_BACK
|
||||||
|
@@ -320,6 +320,11 @@ class Python2Parser(PythonParser):
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
def p_genexpr2(self, args):
|
||||||
|
'''
|
||||||
|
genexpr ::= LOAD_GENEXPR MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1
|
||||||
|
'''
|
||||||
|
|
||||||
def p_expr2(self, args):
|
def p_expr2(self, args):
|
||||||
'''
|
'''
|
||||||
expr ::= LOAD_LOCALS
|
expr ::= LOAD_LOCALS
|
||||||
|
@@ -360,6 +360,11 @@ class Python3Parser(PythonParser):
|
|||||||
load_genexpr ::= BUILD_TUPLE_1 LOAD_GENEXPR LOAD_CONST
|
load_genexpr ::= BUILD_TUPLE_1 LOAD_GENEXPR LOAD_CONST
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
def p_genexpr2(self, args):
|
||||||
|
'''
|
||||||
|
genexpr ::= LOAD_GENEXPR LOAD_CONST MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1
|
||||||
|
'''
|
||||||
|
|
||||||
def p_expr3(self, args):
|
def p_expr3(self, args):
|
||||||
'''
|
'''
|
||||||
expr ::= LOAD_CLASSNAME
|
expr ::= LOAD_CLASSNAME
|
||||||
@@ -473,6 +478,7 @@ class Python3Parser(PythonParser):
|
|||||||
mkfunc ::= {pos_arg}^n LOAD_CONST MAKE_FUNCTION_n
|
mkfunc ::= {pos_arg}^n LOAD_CONST MAKE_FUNCTION_n
|
||||||
mklambda ::= {pos_arg}^n LOAD_LAMBDA MAKE_FUNCTION_n
|
mklambda ::= {pos_arg}^n LOAD_LAMBDA MAKE_FUNCTION_n
|
||||||
mkfunc ::= {pos_arg}^n load_closure LOAD_CONST MAKE_FUNCTION_n
|
mkfunc ::= {pos_arg}^n load_closure LOAD_CONST MAKE_FUNCTION_n
|
||||||
|
genexpr ::= {pos_arg}^n LOAD_GENEXPR MAKE_FUNCTION_n
|
||||||
|
|
||||||
listcomp ::= load_closure expr GET_ITER CALL_FUNCTION_1
|
listcomp ::= load_closure expr GET_ITER CALL_FUNCTION_1
|
||||||
|
|
||||||
|
@@ -637,7 +637,8 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
def n_genexpr(self, node):
|
def n_genexpr(self, node):
|
||||||
start = len(self.f.getvalue())
|
start = len(self.f.getvalue())
|
||||||
self.write('(')
|
self.write('(')
|
||||||
self.comprehension_walk(node, 3)
|
code_index = -6 if self.version > 3.0 else -5
|
||||||
|
self.comprehension_walk(node, iter_index=3, code_index=code_index)
|
||||||
self.write(')')
|
self.write(')')
|
||||||
self.set_pos_info(node, start, len(self.f.getvalue()))
|
self.set_pos_info(node, start, len(self.f.getvalue()))
|
||||||
self.prune()
|
self.prune()
|
||||||
|
@@ -1025,7 +1025,8 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
|
|
||||||
def n_genexpr(self, node):
|
def n_genexpr(self, node):
|
||||||
self.write('(')
|
self.write('(')
|
||||||
self.comprehension_walk(node, iter_index=3)
|
code_index = -6 if self.version > 3.0 else -5
|
||||||
|
self.comprehension_walk(node, iter_index=3, code_index=code_index)
|
||||||
self.write(')')
|
self.write(')')
|
||||||
self.prune()
|
self.prune()
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user