diff --git a/uncompyle6/parsers/parse38.py b/uncompyle6/parsers/parse38.py index e1e9ff13..6e71cdaf 100644 --- a/uncompyle6/parsers/parse38.py +++ b/uncompyle6/parsers/parse38.py @@ -47,8 +47,9 @@ class Python38Parser(Python37Parser): stmt ::= try_except38 stmt ::= whilestmt38 stmt ::= whileTruestmt38 - stmt ::= call + stmt ::= call_stmt + call_stmt ::= call break ::= POP_BLOCK BREAK_LOOP break ::= POP_BLOCK POP_TOP BREAK_LOOP break ::= POP_TOP BREAK_LOOP diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index cf9b6308..75ea2716 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -339,7 +339,11 @@ TABLE_DIRECT = { "raise_stmt1": ("%|raise %c\n", 0), "raise_stmt3": ("%|raise %c, %c, %c\n", 0, 1, 2), # "yield": ( "yield %c", 0), - # "return": ( "%|return %c\n", 0), + + # Note: we have a custom rule, which calls when we don't + # have "return None" + "return": ( "%|return %c\n", 0), + "return_if_stmt": ("return %c\n", 0), "ifstmt": ( "%|if %c:\n%+%c%-", diff --git a/uncompyle6/semantics/customize38.py b/uncompyle6/semantics/customize38.py index 4ffe54a1..d36864d1 100644 --- a/uncompyle6/semantics/customize38.py +++ b/uncompyle6/semantics/customize38.py @@ -46,6 +46,10 @@ def customize_for_version38(self, version): (0, 'expr'), (6, 'store'), (7, 'suite_stmts') ), + "call_stmt": ( + "%|%c\n", 0 + ), + 'except_handler38': ( '%c', (2, 'except_stmts') ), diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 53c00522..20330472 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -510,14 +510,14 @@ class SourceWalker(GenericASTTraversal, object): self.preorder(node[0]) self.prune() else: - self.write(self.indent, "return") # One reason we worry over whether we use "return None" or "return" # is that inside a generator, "return None" is illegal. # Thank you, Python! if self.return_none or not self.is_return_none(node): - self.write(" ") - self.preorder(node[0]) - self.println() + self.default(node) + else: + self.template_engine(("return\n"), node) + self.prune() # stop recursing def n_return_if_stmt(self, node):