You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Fix bug in 2.5- try/else inside ifelsestmt
This commit is contained in:
@@ -13,7 +13,6 @@ case $PYVERSION in
|
||||
2.4)
|
||||
SKIP_TESTS=(
|
||||
[test_binop.py]=1 # need to fix tryelse
|
||||
[test_cgi.py]=1 # need to fix tryelse
|
||||
[test_codecs.py]=1 # need to fix tryelse
|
||||
[test_decorators.py]=1 # Syntax error decorators?
|
||||
[test_dis.py]=1 # We change line numbers - duh!
|
||||
@@ -33,14 +32,12 @@ case $PYVERSION in
|
||||
2.5)
|
||||
SKIP_TESTS=(
|
||||
[test_binop.py]=1 # need to fix tryelse
|
||||
[test_cgi.py]=1 # need to fix tryelse
|
||||
[test_codecs.py]=1 # need to fix tryelse
|
||||
[test_coercion.py]=1
|
||||
[test_contextlib.py]=1
|
||||
[test_decorators.py]=1 # Syntax error decorators?
|
||||
[test_dis.py]=1 # We change line numbers - duh!
|
||||
[test_exceptions.py]=1
|
||||
[test_format.py]=1 # Control flow?
|
||||
[test_frozen.py]=1
|
||||
[test_functools.py]=1
|
||||
[test_grammar.py]=1 # Too many stmts. Handle large stmts
|
||||
@@ -67,7 +64,6 @@ case $PYVERSION in
|
||||
[test_decorators.py]=1 # Syntax Error - look at
|
||||
[test_enumerate.py]=1 # Control flow?
|
||||
[test_file.py]=1 # Control flow?
|
||||
[test_format.py]=1 # Control flow?
|
||||
[test_frozen.py]=1 # Control flow?
|
||||
[test_ftplib.py]=1 # Control flow?
|
||||
[test_funcattrs.py]=1 # Control flow?
|
||||
|
@@ -22,7 +22,6 @@ class Python24Parser(Python25Parser):
|
||||
stmt ::= nop_stmt
|
||||
nop_stmt ::= JUMP_FORWARD POP_TOP COME_FROM
|
||||
|
||||
|
||||
# 2.5+ has two LOAD_CONSTs, one for the number '.'s in a relative import
|
||||
# keep positions similar to simplify semantic actions
|
||||
|
||||
|
@@ -19,6 +19,9 @@ class Python25Parser(Python26Parser):
|
||||
|
||||
return_if_stmt ::= ret_expr RETURN_END_IF JUMP_BACK
|
||||
|
||||
# We have no jumps to jumps, so no "come_froms" but a single "COME_FROM"
|
||||
ifelsestmt ::= testexpr c_stmts_opt jf_cf_pop else_suite COME_FROM
|
||||
|
||||
# Python 2.6 uses ROT_TWO instead of the STORE_xxx
|
||||
# withas is allowed as a "from future" in 2.5
|
||||
# 2.6 and 2.7 do something slightly different
|
||||
@@ -51,6 +54,9 @@ class Python25Parser(Python26Parser):
|
||||
def customize_grammar_rules(self, tokens, customize):
|
||||
# Remove grammar rules inherited from Python 2.6 or Python 2
|
||||
self.remove_rules("""
|
||||
# No jump to jumps in 2.4 so we have a single "COME_FROM", not "come_froms"
|
||||
ifelsestmt ::= testexpr c_stmts_opt jf_cf_pop else_suite come_froms
|
||||
|
||||
setupwith ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 POP_TOP
|
||||
withstmt ::= expr setupwith SETUP_FINALLY suite_stmts_opt
|
||||
POP_BLOCK LOAD_CONST COME_FROM WITH_CLEANUP END_FINALLY
|
||||
|
@@ -176,7 +176,7 @@ class Scanner2(Scanner):
|
||||
come_from_name = 'COME_FROM_%s' % come_from_type
|
||||
pass
|
||||
tokens.append(Token(
|
||||
come_from_name, None, repr(jump_offset),
|
||||
come_from_name, jump_offset, repr(jump_offset),
|
||||
offset="%s_%d" % (offset, jump_idx),
|
||||
has_arg = True))
|
||||
jump_idx += 1
|
||||
|
@@ -166,7 +166,7 @@ class Scanner26(scan.Scanner2):
|
||||
for jump_offset in sorted(jump_targets[offset], reverse=True):
|
||||
if jump_offset != last_jump_offset:
|
||||
tokens.append(Token(
|
||||
'COME_FROM', None, repr(jump_offset),
|
||||
'COME_FROM', jump_offset, repr(jump_offset),
|
||||
offset="%s_%d" % (offset, jump_idx),
|
||||
has_arg = True))
|
||||
jump_idx += 1
|
||||
|
@@ -248,7 +248,7 @@ class Scanner3(Scanner):
|
||||
elif inst.offset in self.except_targets:
|
||||
come_from_name = 'COME_FROM_EXCEPT_CLAUSE'
|
||||
tokens.append(Token(come_from_name,
|
||||
None, repr(jump_offset),
|
||||
jump_offset, repr(jump_offset),
|
||||
offset='%s_%s' % (inst.offset, jump_idx),
|
||||
has_arg = True, opc=self.opc))
|
||||
jump_idx += 1
|
||||
|
Reference in New Issue
Block a user