Add 3.0 try/except rule

This commit is contained in:
rocky
2019-11-15 23:39:36 -05:00
parent bc8907e752
commit 44f0ba0efb
2 changed files with 15 additions and 4 deletions

View File

@@ -12,6 +12,8 @@ class Python30Parser(Python31Parser):
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
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM POP_TOP
compare_chained2 ::= expr COMPARE_OP RETURN_END_IF_LAMBDA
@@ -89,6 +91,11 @@ class Python30Parser(Python31Parser):
LOAD_FAST FOR_ITER store dict_comp_iter
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

View File

@@ -182,12 +182,16 @@ def customize_for_version3(self, version):
# since we pick up the iteration variable some other way and
# we definitely don't include in the source _[dd].
TABLE_DIRECT.update({
'ifstmt30': ( "%|if %c:\n%+%c%-",
"ifstmt30": ( "%|if %c:\n%+%c%-",
(0, "testfalse_then"),
(1, "_ifstmts_jump30") ),
'ifnotstmt30': ( "%|if not %c:\n%+%c%-",
(0, "testtrue_then"),
(1, "_ifstmts_jump30") ),
"ifnotstmt30": ( "%|if not %c:\n%+%c%-",
(0, "testtrue_then"),
(1, "_ifstmts_jump30") ),
"try_except30": ( "%|try:\n%+%c%-%c\n\n",
(1, "suite_stmts_opt"),
(4, "except_handler") ),
})
def n_comp_iter(node):