Fix bug in return-optimized try stmt

This commit is contained in:
rocky
2017-11-09 11:01:29 -05:00
parent b9dfba7400
commit 74731a9d42
3 changed files with 11 additions and 0 deletions

Binary file not shown.

View File

@@ -63,6 +63,12 @@ class Python36Parser(Python35Parser):
except_return ::= POP_TOP POP_TOP POP_TOP return_stmts except_return ::= POP_TOP POP_TOP POP_TOP return_stmts
try_middle ::= JUMP_FORWARD COME_FROM_EXCEPT except_return try_middle ::= JUMP_FORWARD COME_FROM_EXCEPT except_return
# Try middle following a return_stmts
try_middle36 ::= COME_FROM_EXCEPT except_stmts END_FINALLY
stmt ::= trystmt36
trystmt36 ::= SETUP_EXCEPT return_stmts try_middle36 opt_come_from_except
""" """
def add_custom_rules(self, tokens, customize): def add_custom_rules(self, tokens, customize):

View File

@@ -418,6 +418,11 @@ class SourceWalker(GenericASTTraversal, object):
# 'unmapexpr': ( '{**%c}', 0), # done by n_unmapexpr # 'unmapexpr': ( '{**%c}', 0), # done by n_unmapexpr
}) })
if version >= 3.6:
TABLE_DIRECT.update({
'trystmt36': ( '%|try:\n%+%c%-%c\n\n', 1, 2 ),
})
def n_async_call_function(node): def n_async_call_function(node):
self.f.write('async ') self.f.write('async ')
node.kind == 'call_function' node.kind == 'call_function'