You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
More 2.6.9 bugs fixed
* break loop parsing bug * ifelsestmt semantic-action bug in handling else
This commit is contained in:
BIN
test/bytecode_2.6/06_for_break.pyc
Normal file
BIN
test/bytecode_2.6/06_for_break.pyc
Normal file
Binary file not shown.
11
test/simple_source/stmts/06_for_break.py
Normal file
11
test/simple_source/stmts/06_for_break.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# 2.6.9 _strptime.py
|
||||
# In 2.6 bug in handling BREAK_LOOP followed by JUMP_BACK
|
||||
# So added rule:
|
||||
# break_stmt ::= BREAK_LOOP JUMP_BACK
|
||||
for value in __file__:
|
||||
if value:
|
||||
if (value and __name__):
|
||||
pass
|
||||
else:
|
||||
tz = 'a'
|
||||
break
|
@@ -91,13 +91,21 @@ class Python26Parser(Python2Parser):
|
||||
|
||||
def p_stmt26(self, args):
|
||||
"""
|
||||
# We use filler as a placeholder to keep nonterminal positions
|
||||
# the same across different grammars so that the same semantic actions
|
||||
# can be used
|
||||
filler ::=
|
||||
|
||||
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 come_from_pop
|
||||
assert2 ::= assert_expr jmp_true LOAD_ASSERT expr RAISE_VARARGS_2 come_from_pop
|
||||
|
||||
ifelsestmt ::= testexpr c_stmts_opt jf_pop else_suite COME_FROM
|
||||
ifelsestmt ::= testexpr c_stmts_opt else_suitel come_froms POP_TOP
|
||||
break_stmt ::= BREAK_LOOP JUMP_BACK
|
||||
|
||||
# Semantic actions want else_suitel to be at index 2 or 3
|
||||
# Semantic actions want the else to be at position 3
|
||||
ifelsestmt ::= testexpr c_stmts_opt jf_pop else_suite COME_FROM
|
||||
ifelsestmt ::= testexpr c_stmts_opt filler else_suitel come_froms POP_TOP
|
||||
|
||||
# Semantic actions want else_suitel to be at index 3
|
||||
ifelsestmtl ::= testexpr c_stmts_opt jb_cf_pop else_suitel
|
||||
ifelsestmtc ::= testexpr c_stmts_opt ja_cf_pop else_suitec
|
||||
|
||||
@@ -119,6 +127,7 @@ class Python26Parser(Python2Parser):
|
||||
|
||||
iflaststmtl ::= testexpr c_stmts_opt JUMP_BACK come_from_pop
|
||||
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE come_from_pop
|
||||
|
||||
"""
|
||||
|
||||
def p_comp26(self, args):
|
||||
|
@@ -850,10 +850,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.prune() # stop recursing
|
||||
|
||||
def n_ifelsestmt(self, node, preprocess=False):
|
||||
if node[2].type.startswith('else_suite'):
|
||||
else_suite = node[2]
|
||||
elif node[3].type.startswith('else_suite'):
|
||||
else_suite = node[3]
|
||||
else_suite = node[3]
|
||||
|
||||
n = else_suite[0]
|
||||
|
||||
|
Reference in New Issue
Block a user