You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
More Python 2 and 3 deparsing bugs fixed
* while + if break * try + finall /pass
This commit is contained in:
BIN
test/bytecode_2.7/05_try_finally_pass.pyc
Normal file
BIN
test/bytecode_2.7/05_try_finally_pass.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_2.7/10_if_break_finally.pyc
Normal file
BIN
test/bytecode_2.7/10_if_break_finally.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.5/05_try_finally_pass.pyc
Normal file
BIN
test/bytecode_3.5/05_try_finally_pass.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.5/10_if_break_finally.pyc
Normal file
BIN
test/bytecode_3.5/10_if_break_finally.pyc
Normal file
Binary file not shown.
10
test/simple_source/stmts/05_try_finally_pass.py
Normal file
10
test/simple_source/stmts/05_try_finally_pass.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Tests and empty finally section
|
||||||
|
# tryfinallystmt ::= SETUP_FINALLY e_suite_stmts_opt
|
||||||
|
# POP_BLOCK LOAD_CONST COME_FROM e_suite_stmts_opt END_FINALLY
|
||||||
|
#
|
||||||
|
|
||||||
|
try:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
pass
|
||||||
|
pass
|
10
test/simple_source/stmts/10_if_break_finally.py
Normal file
10
test/simple_source/stmts/10_if_break_finally.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Tests
|
||||||
|
# while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM
|
||||||
|
# tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt POP_BLOCK
|
||||||
|
|
||||||
|
try:
|
||||||
|
while 1:
|
||||||
|
if __file__:
|
||||||
|
break
|
||||||
|
finally:
|
||||||
|
pass
|
@@ -215,6 +215,5 @@ del def_op, name_op, jrel_op, jabs_op
|
|||||||
from uncompyle6 import PYTHON_VERSION
|
from uncompyle6 import PYTHON_VERSION
|
||||||
if PYTHON_VERSION == 2.7:
|
if PYTHON_VERSION == 2.7:
|
||||||
import dis
|
import dis
|
||||||
# print(dis.opmap.items())
|
# print(set(dis.opmap.items()) - set(opmap.items()))
|
||||||
print(set(dis.opmap.items()) - set(opmap.items()))
|
|
||||||
assert all(item in opmap.items() for item in dis.opmap.items())
|
assert all(item in opmap.items() for item in dis.opmap.items())
|
||||||
|
@@ -448,7 +448,7 @@ def python_parser(version, co, out=sys.stdout, showasm=False,
|
|||||||
print(t)
|
print(t)
|
||||||
|
|
||||||
# For heavy grammar debugging
|
# For heavy grammar debugging
|
||||||
# parser_debug = {'rules': True, 'transition': True, 'reduce' : True}
|
parser_debug = {'rules': True, 'transition': True, 'reduce' : True}
|
||||||
p = get_python_parser(version, parser_debug)
|
p = get_python_parser(version, parser_debug)
|
||||||
return parse(p, tokens, customize)
|
return parse(p, tokens, customize)
|
||||||
|
|
||||||
|
@@ -268,7 +268,7 @@ class Python2Parser(PythonParser):
|
|||||||
try_middle COME_FROM
|
try_middle COME_FROM
|
||||||
|
|
||||||
# this is nested inside a trystmt
|
# this is nested inside a trystmt
|
||||||
tryfinallystmt ::= SETUP_FINALLY suite_stmts
|
tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
|
||||||
POP_BLOCK LOAD_CONST
|
POP_BLOCK LOAD_CONST
|
||||||
COME_FROM suite_stmts_opt END_FINALLY
|
COME_FROM suite_stmts_opt END_FINALLY
|
||||||
|
|
||||||
@@ -328,7 +328,10 @@ class Python2Parser(PythonParser):
|
|||||||
return_stmts
|
return_stmts
|
||||||
POP_BLOCK COME_FROM
|
POP_BLOCK COME_FROM
|
||||||
|
|
||||||
|
while1stmt_pre ::= SETUP_LOOP l_stmts JUMP_BACK
|
||||||
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
|
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK COME_FROM
|
||||||
|
while1stmt ::= SETUP_LOOP l_stmts JUMP_BACK POP_BLOCK COME_FROM
|
||||||
|
|
||||||
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
while1stmt ::= SETUP_LOOP return_stmts COME_FROM
|
||||||
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
|
while1elsestmt ::= SETUP_LOOP l_stmts JUMP_BACK else_suite COME_FROM
|
||||||
|
|
||||||
|
@@ -263,7 +263,7 @@ class Python3Parser(PythonParser):
|
|||||||
try_middle _come_from _come_from
|
try_middle _come_from _come_from
|
||||||
|
|
||||||
# this is nested inside a trystmt
|
# this is nested inside a trystmt
|
||||||
tryfinallystmt ::= SETUP_FINALLY suite_stmts
|
tryfinallystmt ::= SETUP_FINALLY suite_stmts_opt
|
||||||
POP_BLOCK LOAD_CONST
|
POP_BLOCK LOAD_CONST
|
||||||
COME_FROM suite_stmts_opt END_FINALLY
|
COME_FROM suite_stmts_opt END_FINALLY
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user