You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Add 3.0 try/except rule
This commit is contained in:
@@ -12,6 +12,8 @@ class Python30Parser(Python31Parser):
|
|||||||
def p_30(self, args):
|
def p_30(self, args):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
pt_bp ::= POP_TOP POP_BLOCK
|
||||||
|
|
||||||
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 COME_FROM POP_TOP
|
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 COME_FROM POP_TOP
|
||||||
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM POP_TOP
|
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM POP_TOP
|
||||||
compare_chained2 ::= expr COMPARE_OP RETURN_END_IF_LAMBDA
|
compare_chained2 ::= expr COMPARE_OP RETURN_END_IF_LAMBDA
|
||||||
@@ -89,6 +91,11 @@ class Python30Parser(Python31Parser):
|
|||||||
LOAD_FAST FOR_ITER store dict_comp_iter
|
LOAD_FAST FOR_ITER store dict_comp_iter
|
||||||
JUMP_BACK
|
JUMP_BACK
|
||||||
|
|
||||||
|
stmt ::= try_except30
|
||||||
|
try_except30 ::= SETUP_EXCEPT suite_stmts_opt
|
||||||
|
_come_froms pt_bp
|
||||||
|
except_handler opt_come_from_except
|
||||||
|
|
||||||
# From Python 2.6
|
# From Python 2.6
|
||||||
|
|
||||||
|
|
||||||
|
@@ -182,12 +182,16 @@ def customize_for_version3(self, version):
|
|||||||
# since we pick up the iteration variable some other way and
|
# since we pick up the iteration variable some other way and
|
||||||
# we definitely don't include in the source _[dd].
|
# we definitely don't include in the source _[dd].
|
||||||
TABLE_DIRECT.update({
|
TABLE_DIRECT.update({
|
||||||
'ifstmt30': ( "%|if %c:\n%+%c%-",
|
"ifstmt30": ( "%|if %c:\n%+%c%-",
|
||||||
(0, "testfalse_then"),
|
(0, "testfalse_then"),
|
||||||
(1, "_ifstmts_jump30") ),
|
(1, "_ifstmts_jump30") ),
|
||||||
'ifnotstmt30': ( "%|if not %c:\n%+%c%-",
|
"ifnotstmt30": ( "%|if not %c:\n%+%c%-",
|
||||||
(0, "testtrue_then"),
|
(0, "testtrue_then"),
|
||||||
(1, "_ifstmts_jump30") ),
|
(1, "_ifstmts_jump30") ),
|
||||||
|
"try_except30": ( "%|try:\n%+%c%-%c\n\n",
|
||||||
|
(1, "suite_stmts_opt"),
|
||||||
|
(4, "except_handler") ),
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
def n_comp_iter(node):
|
def n_comp_iter(node):
|
||||||
|
Reference in New Issue
Block a user