You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Attempt to get 3.5 RETURN_END_IF working
This feels hacky and I'm not sure is quite right. Untili we understand better what to do though, we'll go with it.
This commit is contained in:
@@ -603,11 +603,16 @@ class Python35onParser(Python3Parser):
|
|||||||
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
WITH_CLEANUP_START WITH_CLEANUP_FINISH END_FINALLY
|
||||||
|
|
||||||
|
|
||||||
# Python 3.5+_ does jump optimization that scanner3.py's detect
|
# Python 3.5+ does jump optimization
|
||||||
# structure can't fully work out. So for now let's allow
|
# In <.3.5 the below is a JUMP_FORWARD to a JUMP_ABSOLUTE.
|
||||||
# RETURN_END_IF the same as RETURN_VAL
|
# in return_stmt, we will need the semantic actions in pysource.py
|
||||||
|
# to work out whether to dedent or not based on the presence of
|
||||||
|
# RETURN_END_IF vs RETURN_VALUE
|
||||||
|
|
||||||
|
ifelsestmtc ::= testexpr c_stmts_opt JUMP_FORWARD else_suitec
|
||||||
return_stmt ::= ret_expr RETURN_END_IF
|
return_stmt ::= ret_expr RETURN_END_IF
|
||||||
|
|
||||||
|
|
||||||
# Python 3.3+ also has yield from. 3.5 does it
|
# Python 3.3+ also has yield from. 3.5 does it
|
||||||
# differently than 3.3, 3.4
|
# differently than 3.3, 3.4
|
||||||
|
|
||||||
|
@@ -710,6 +710,11 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
if self.return_none or node != AST('return_stmt', [AST('ret_expr', [NONE]), Token('RETURN_VALUE')]):
|
if self.return_none or node != AST('return_stmt', [AST('ret_expr', [NONE]), Token('RETURN_VALUE')]):
|
||||||
self.write(' ')
|
self.write(' ')
|
||||||
self.preorder(node[0])
|
self.preorder(node[0])
|
||||||
|
# 3.5 does jump optimization. The RETURN_END_IF in the return
|
||||||
|
# statement means to dedent. Earlier versions will just have
|
||||||
|
# RETURN_VALUE
|
||||||
|
if self.version >= 3.5 and node[-1] == 'RETURN_END_IF':
|
||||||
|
self.indentLess()
|
||||||
self.println()
|
self.println()
|
||||||
self.prune() # stop recursing
|
self.prune() # stop recursing
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user