You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Python 3.0 if/else handling
This commit is contained in:
BIN
test/bytecode_3.0/03_ifelse.pyc
Normal file
BIN
test/bytecode_3.0/03_ifelse.pyc
Normal file
Binary file not shown.
9
test/simple_source/bug30/03_ifelse.py
Normal file
9
test/simple_source/bug30/03_ifelse.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Adapted from 3.0 base64
|
||||||
|
# Problem was handling if/else which
|
||||||
|
# needs to be like Python 2.6 (and not like 2.7 or 3.1)
|
||||||
|
def main(args, f):
|
||||||
|
"""Small main program"""
|
||||||
|
if args and args[0] != '-':
|
||||||
|
func(f, sys.stdout.buffer)
|
||||||
|
else:
|
||||||
|
func(sys.stdin.buffer, sys.stdout.buffer)
|
@@ -1439,15 +1439,6 @@ class Python3Parser(PythonParser):
|
|||||||
""",
|
""",
|
||||||
nop_func
|
nop_func
|
||||||
)
|
)
|
||||||
if self.version == 3.0:
|
|
||||||
self.addRule(
|
|
||||||
"""
|
|
||||||
tryelsestmtl3 ::= SETUP_EXCEPT suite_stmts_opt POP_BLOCK
|
|
||||||
except_handler COME_FROM else_suitel
|
|
||||||
JUMP_FORWARD come_froms POP_TOP
|
|
||||||
""",
|
|
||||||
nop_func
|
|
||||||
)
|
|
||||||
|
|
||||||
custom_ops_processed.add(opname)
|
custom_ops_processed.add(opname)
|
||||||
elif opname_base in ("UNPACK_EX",):
|
elif opname_base in ("UNPACK_EX",):
|
||||||
|
@@ -47,6 +47,9 @@ class Python30Parser(Python31Parser):
|
|||||||
iflaststmtl ::= testexpr c_stmts_opt jb_pop_top
|
iflaststmtl ::= testexpr c_stmts_opt jb_pop_top
|
||||||
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE COME_FROM POP_TOP
|
iflaststmt ::= testexpr c_stmts_opt JUMP_ABSOLUTE COME_FROM POP_TOP
|
||||||
|
|
||||||
|
jf_cf_pop ::= JUMP_FORWARD come_froms POP_TOP
|
||||||
|
ifelsestmt ::= testexpr c_stmts_opt jf_cf_pop else_suite COME_FROM
|
||||||
|
|
||||||
withasstmt ::= expr setupwithas store suite_stmts_opt
|
withasstmt ::= expr setupwithas store suite_stmts_opt
|
||||||
POP_BLOCK LOAD_CONST COME_FROM_FINALLY
|
POP_BLOCK LOAD_CONST COME_FROM_FINALLY
|
||||||
LOAD_FAST DELETE_FAST WITH_CLEANUP END_FINALLY
|
LOAD_FAST DELETE_FAST WITH_CLEANUP END_FINALLY
|
||||||
|
Reference in New Issue
Block a user