From 278af38df6ced9b471562c6d12d0813b2b97fb72 Mon Sep 17 00:00:00 2001 From: rocky Date: Fri, 7 Feb 2020 16:17:47 -0500 Subject: [PATCH] conditional -> if_exp ... to match Python IfExp AST --- .../branching/02_ifelse_lambda.py | 2 +- test/simple_source/bug26/03_weird26.py | 2 +- test/simple_source/bug27+/03_not_dead_code.py | 4 +-- uncompyle6/parser.py | 2 +- uncompyle6/parsers/parse23.py | 2 +- uncompyle6/parsers/parse24.py | 2 +- uncompyle6/parsers/parse25.py | 11 +++--- uncompyle6/parsers/parse26.py | 30 ++++++++-------- uncompyle6/parsers/parse27.py | 31 ++++++++-------- uncompyle6/parsers/parse3.py | 28 +++++++-------- uncompyle6/parsers/parse32.py | 2 +- uncompyle6/parsers/parse36.py | 6 ++-- uncompyle6/parsers/parse37.py | 36 +++++++++---------- uncompyle6/parsers/parse37base.py | 9 +++-- uncompyle6/semantics/consts.py | 24 ++++++------- uncompyle6/semantics/customize3.py | 2 +- uncompyle6/semantics/customize36.py | 2 +- uncompyle6/semantics/customize37.py | 4 +-- uncompyle6/semantics/helper.py | 2 +- 19 files changed, 98 insertions(+), 103 deletions(-) diff --git a/test/simple_source/branching/02_ifelse_lambda.py b/test/simple_source/branching/02_ifelse_lambda.py index 6b68ee52..9de82c93 100644 --- a/test/simple_source/branching/02_ifelse_lambda.py +++ b/test/simple_source/branching/02_ifelse_lambda.py @@ -22,7 +22,7 @@ assert i[0]('a') == True assert i[0]('A') == False # Issue #170. Bug is needing an "conditional_not_lambda" grammar rule -# in addition the the "if_expr_lambda" rule +# in addition the the "if_exp_lambda" rule j = lambda a: False if not a else True assert j(True) == True assert j(False) == False diff --git a/test/simple_source/bug26/03_weird26.py b/test/simple_source/bug26/03_weird26.py index 34e176b0..9b583eed 100644 --- a/test/simple_source/bug26/03_weird26.py +++ b/test/simple_source/bug26/03_weird26.py @@ -8,7 +8,7 @@ list(x for x in range(10) if x % 2 if x % 3) # expresion which evaluates True unconditionally, # but leave dead code or junk around that we have to match on. -# Tests "if_expr_true" rule +# Tests "if_exp_true" rule 5 if 1 else 2 0 or max(5, 3) if 0 else 3 diff --git a/test/simple_source/bug27+/03_not_dead_code.py b/test/simple_source/bug27+/03_not_dead_code.py index f4698761..61a2309c 100644 --- a/test/simple_source/bug27+/03_not_dead_code.py +++ b/test/simple_source/bug27+/03_not_dead_code.py @@ -1,6 +1,6 @@ # Bug found in 2.7 test_itertools.py -# Bug was erroneously using reduction to if_expr_true -# A proper fix would be to use if_expr_true only when we +# Bug was erroneously using reduction to if_exp_true +# A proper fix would be to use if_exp_true only when we # can determine there is or was dead code. from itertools import izip_longest for args in [['abc', range(6)]]: diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index df1c9f4c..fba35500 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -570,7 +570,7 @@ class PythonParser(GenericASTBuilder): _mklambda ::= mklambda - expr ::= conditional + expr ::= if_exp ret_expr ::= expr ret_expr ::= ret_and diff --git a/uncompyle6/parsers/parse23.py b/uncompyle6/parsers/parse23.py index 6e29d9e8..166de860 100644 --- a/uncompyle6/parsers/parse23.py +++ b/uncompyle6/parsers/parse23.py @@ -49,7 +49,7 @@ class Python23Parser(Python24Parser): and2 ::= _jump jmp_false COME_FROM expr COME_FROM alias ::= IMPORT_NAME attributes store - conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM + if_exp ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM ''' def customize_grammar_rules(self, tokens, customize): diff --git a/uncompyle6/parsers/parse24.py b/uncompyle6/parsers/parse24.py index bc3e3625..b758c52a 100644 --- a/uncompyle6/parsers/parse24.py +++ b/uncompyle6/parsers/parse24.py @@ -58,7 +58,7 @@ class Python24Parser(Python25Parser): def remove_rules_24(self): self.remove_rules(""" - expr ::= conditional + expr ::= if_exp """) diff --git a/uncompyle6/parsers/parse25.py b/uncompyle6/parsers/parse25.py index a969ef47..378241e8 100644 --- a/uncompyle6/parsers/parse25.py +++ b/uncompyle6/parsers/parse25.py @@ -81,13 +81,12 @@ class Python25Parser(Python26Parser): return_stmt_lambda ::= ret_expr RETURN_VALUE_LAMBDA setupwithas ::= DUP_TOP LOAD_ATTR ROT_TWO LOAD_ATTR CALL_FUNCTION_0 setup_finally stmt ::= classdefdeco - stmt ::= if_expr_lambda - stmt ::= conditional_not_lambda - if_expr_lambda ::= expr jmp_false_then expr return_if_lambda - return_stmt_lambda LAMBDA_MARKER - conditional_not_lambda - ::= expr jmp_true_then expr return_if_lambda + stmt ::= if_exp_lambda + stmt ::= if_exp_not_lambda + if_exp_lambda ::= expr jmp_false_then expr return_if_lambda return_stmt_lambda LAMBDA_MARKER + if_exp_not_lambda ::= expr jmp_true_then expr return_if_lambda + return_stmt_lambda LAMBDA_MARKER """) super(Python25Parser, self).customize_grammar_rules(tokens, customize) if self.version == 2.5: diff --git a/uncompyle6/parsers/parse26.py b/uncompyle6/parsers/parse26.py index 383966b2..66aa9674 100644 --- a/uncompyle6/parsers/parse26.py +++ b/uncompyle6/parsers/parse26.py @@ -283,11 +283,11 @@ class Python26Parser(Python2Parser): kvlist ::= kvlist kv3 # Note: preserve positions 0 2 and 4 for semantic actions - conditional_not ::= expr jmp_true expr jf_cf_pop expr COME_FROM - conditional ::= expr jmp_false expr jf_cf_pop expr come_from_opt - conditional ::= expr jmp_false expr ja_cf_pop expr + if_exp_not ::= expr jmp_true expr jf_cf_pop expr COME_FROM + if_exp ::= expr jmp_false expr jf_cf_pop expr come_from_opt + if_exp ::= expr jmp_false expr ja_cf_pop expr - expr ::= conditional_not + expr ::= if_exp_not and ::= expr JUMP_IF_FALSE POP_TOP expr JUMP_IF_FALSE POP_TOP @@ -311,27 +311,27 @@ class Python26Parser(Python2Parser): compare_chained2 ::= expr COMPARE_OP return_lambda return_if_lambda ::= RETURN_END_IF_LAMBDA POP_TOP - stmt ::= if_expr_lambda - stmt ::= conditional_not_lambda - if_expr_lambda ::= expr jmp_false_then expr return_if_lambda + stmt ::= if_exp_lambda + stmt ::= if_exp_not_lambda + if_exp_lambda ::= expr jmp_false_then expr return_if_lambda return_stmt_lambda LAMBDA_MARKER - conditional_not_lambda ::= + if_exp_not_lambda ::= expr jmp_true_then expr return_if_lambda return_stmt_lambda LAMBDA_MARKER - # if_expr_true are for conditions which always evaluate true + # if_exp_true are for conditions which always evaluate true # There is dead or non-optional remnants of the condition code though, # and we use that to match on to reconstruct the source more accurately - expr ::= if_expr_true - if_expr_true ::= expr jf_pop expr COME_FROM + expr ::= if_exp_true + if_exp_true ::= expr jf_pop expr COME_FROM # This comes from # 0 or max(5, 3) if 0 else 3 # where there seems to be an additional COME_FROM at the # end. Not sure if this is appropriately named or # is the best way to handle - expr ::= conditional_false - conditional_false ::= conditional COME_FROM + expr ::= if_exp_false + if_exp_false ::= if_exp COME_FROM """ @@ -366,10 +366,10 @@ class Python26Parser(Python2Parser): if ast[1] is None: return False - # For now, we won't let the 2nd 'expr' be a "conditional_not" + # For now, we won't let the 2nd 'expr' be a "if_exp_not" # However in < 2.6 where we don't have if/else expression it *can* # be. - if self.version >= 2.6 and ast[2][0] == 'conditional_not': + if self.version >= 2.6 and ast[2][0] == "if_exp_not": return True test_index = last diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index 5313113d..d41412b9 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -116,17 +116,17 @@ class Python27Parser(Python2Parser): compare_chained2 ::= expr COMPARE_OP return_lambda compare_chained2 ::= expr COMPARE_OP return_lambda - # if_expr_true are for conditions which always evaluate true + # if_exp_true are for conditions which always evaluate true # There is dead or non-optional remnants of the condition code though, # and we use that to match on to reconstruct the source more accurately. # FIXME: we should do analysis and reduce *only* if there is dead code? # right now we check that expr is "or". Any other nodes types? - expr ::= if_expr_true - if_expr_true ::= expr JUMP_FORWARD expr COME_FROM + expr ::= if_exp_true + if_exp_true ::= expr JUMP_FORWARD expr COME_FROM - conditional ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM - conditional ::= expr jmp_false expr JUMP_ABSOLUTE expr + if_exp ::= expr jmp_false expr JUMP_FORWARD expr COME_FROM + if_exp ::= expr jmp_false expr JUMP_ABSOLUTE expr """ def p_stmt27(self, args): @@ -190,16 +190,15 @@ class Python27Parser(Python2Parser): # Common with 2.6 return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM - stmt ::= if_expr_lambda - stmt ::= conditional_not_lambda - if_expr_lambda ::= expr jmp_false expr return_if_lambda + stmt ::= if_exp_lambda + stmt ::= if_exp_not_lambda + if_exp_lambda ::= expr jmp_false expr return_if_lambda return_stmt_lambda LAMBDA_MARKER - conditional_not_lambda - ::= expr jmp_true expr return_if_lambda + if_exp_not_lambda ::= expr jmp_true expr return_if_lambda return_stmt_lambda LAMBDA_MARKER - expr ::= conditional_not - conditional_not ::= expr jmp_true expr _jump expr COME_FROM + expr ::= if_exp_not + if_exp_not ::= expr jmp_true expr _jump expr COME_FROM kv3 ::= expr expr STORE_MAP """ @@ -229,7 +228,7 @@ class Python27Parser(Python2Parser): } self.check_reduce["and"] = "AST" - self.check_reduce["conditional"] = "AST" + self.check_reduce["if_exp"] = "AST" self.check_reduce["except_handler"] = "tokens" self.check_reduce["except_handler_else"] = "tokens" @@ -241,7 +240,7 @@ class Python27Parser(Python2Parser): self.check_reduce["list_if_not"] = "AST" self.check_reduce["list_if"] = "AST" self.check_reduce["comp_if"] = "AST" - self.check_reduce["if_expr_true"] = "tokens" + self.check_reduce["if_exp_true"] = "tokens" self.check_reduce["whilestmt"] = "tokens" return @@ -266,7 +265,7 @@ class Python27Parser(Python2Parser): return tokens[first].offset < jmp_false[0].attr < tokens[last].offset pass elif (rule[0], rule[1][0:5]) == ( - "conditional", + "if_exp", ("expr", "jmp_false", "expr", "JUMP_ABSOLUTE", "expr")): jmp_false = ast[1] if jmp_false[0] == "POP_JUMP_IF_FALSE": @@ -336,7 +335,7 @@ class Python27Parser(Python2Parser): while (tokens[i] != "JUMP_BACK"): i -= 1 return tokens[i].attr != tokens[i-1].attr - elif rule[0] == "if_expr_true": + elif rule[0] == "if_exp_true": return (first) > 0 and tokens[first-1] == "POP_JUMP_IF_FALSE" return False diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index f52076ff..f22f2a9c 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -349,13 +349,12 @@ class Python3Parser(PythonParser): def p_stmt3(self, args): """ - stmt ::= if_expr_lambda + stmt ::= if_exp_lambda - stmt ::= conditional_not_lambda - if_expr_lambda ::= expr jmp_false expr return_if_lambda + stmt ::= if_exp_not_lambda + if_exp_lambda ::= expr jmp_false expr return_if_lambda return_stmt_lambda LAMBDA_MARKER - conditional_not_lambda - ::= expr jmp_true expr return_if_lambda + if_exp_not_lambda ::= expr jmp_true expr return_if_lambda return_stmt_lambda LAMBDA_MARKER return_stmt_lambda ::= ret_expr RETURN_VALUE_LAMBDA @@ -469,18 +468,18 @@ class Python3Parser(PythonParser): def p_expr3(self, args): """ expr ::= LOAD_STR - expr ::= conditionalnot - conditionalnot ::= expr jmp_true expr jump_forward_else expr COME_FROM + expr ::= if_exp_not + if_exp_not ::= expr jmp_true expr jump_forward_else expr COME_FROM # a JUMP_FORWARD to another JUMP_FORWARD can get turned into # a JUMP_ABSOLUTE with no COME_FROM - conditional ::= expr jmp_false expr jump_absolute_else expr + if_exp ::= expr jmp_false expr jump_absolute_else expr - # if_expr_true are for conditions which always evaluate true + # if_exp_true are for conditions which always evaluate true # There is dead or non-optional remnants of the condition code though, # and we use that to match on to reconstruct the source more accurately - expr ::= if_expr_true - if_expr_true ::= expr JUMP_FORWARD expr COME_FROM + expr ::= if_exp_true + if_exp_true ::= expr JUMP_FORWARD expr COME_FROM """ @staticmethod @@ -705,12 +704,11 @@ class Python3Parser(PythonParser): stmt ::= assign2_pypy assign3_pypy ::= expr expr expr store store store assign2_pypy ::= expr expr store store - stmt ::= if_expr_lambda - stmt ::= conditional_not_lambda + stmt ::= if_exp_lambda + stmt ::= if_exp_not_lambda if_expr_lambda ::= expr jmp_false expr return_if_lambda return_lambda LAMBDA_MARKER - conditional_not_lambda - ::= expr jmp_true expr return_if_lambda + if_exp_not_lambda ::= expr jmp_true expr return_if_lambda return_lambda LAMBDA_MARKER """, nop_func, diff --git a/uncompyle6/parsers/parse32.py b/uncompyle6/parsers/parse32.py index 4d3da67e..be262985 100644 --- a/uncompyle6/parsers/parse32.py +++ b/uncompyle6/parsers/parse32.py @@ -17,7 +17,7 @@ class Python32Parser(Python3Parser): def p_32to35(self, args): """ - conditional ::= expr jmp_false expr jump_forward_else expr COME_FROM + if_exp ::= expr jmp_false expr jump_forward_else expr COME_FROM # compare_chained2 is used in a "chained_compare": x <= y <= z # used exclusively in compare_chained diff --git a/uncompyle6/parsers/parse36.py b/uncompyle6/parsers/parse36.py index 54d5a8c9..38f40afb 100644 --- a/uncompyle6/parsers/parse36.py +++ b/uncompyle6/parsers/parse36.py @@ -65,7 +65,7 @@ class Python36Parser(Python35Parser): jf_cf ::= JUMP_FORWARD COME_FROM cf_jf_else ::= come_froms JUMP_FORWARD ELSE - conditional ::= expr jmp_false expr jf_cf expr COME_FROM + if_exp ::= expr jmp_false expr jf_cf expr COME_FROM async_for_stmt ::= SETUP_LOOP expr GET_AITER @@ -158,8 +158,8 @@ class Python36Parser(Python35Parser): # that and then we can remove this. def p_37conditionals(self, args): """ - expr ::= conditional37 - conditional37 ::= expr expr jf_cfs expr COME_FROM + expr ::= if_exp37 + if_exp37 ::= expr expr jf_cfs expr COME_FROM jf_cfs ::= JUMP_FORWARD _come_froms ifelsestmt ::= testexpr c_stmts_opt jf_cfs else_suite opt_come_from_except """ diff --git a/uncompyle6/parsers/parse37.py b/uncompyle6/parsers/parse37.py index 4fe52146..e62bcdf2 100644 --- a/uncompyle6/parsers/parse37.py +++ b/uncompyle6/parsers/parse37.py @@ -186,11 +186,11 @@ class Python37Parser(Python37BaseParser): _mklambda ::= mklambda - expr ::= conditional + expr ::= if_exp - ret_expr ::= expr - ret_expr ::= ret_and - ret_expr ::= ret_or + ret_expr ::= expr + ret_expr ::= ret_and + ret_expr ::= ret_or ret_expr_or_cond ::= ret_expr ret_expr_or_cond ::= ret_cond @@ -406,7 +406,7 @@ class Python37Parser(Python37BaseParser): def p_32on(self, args): """ - conditional::= expr jmp_false expr jump_forward_else expr COME_FROM + if_exp::= expr jmp_false expr jump_forward_else expr COME_FROM # compare_chained2 is used in a "chained_compare": x <= y <= z # used exclusively in compare_chained @@ -631,8 +631,8 @@ class Python37Parser(Python37BaseParser): def p_37conditionals(self, args): """ - expr ::= conditional37 - conditional37 ::= expr expr jf_cfs expr COME_FROM + expr ::= if_exp37 + if_exp37 ::= expr expr jf_cfs expr COME_FROM jf_cfs ::= JUMP_FORWARD _come_froms ifelsestmt ::= testexpr c_stmts_opt jf_cfs else_suite opt_come_from_except @@ -713,18 +713,18 @@ class Python37Parser(Python37BaseParser): def p_expr3(self, args): """ - expr ::= conditionalnot - conditionalnot ::= expr jmp_true expr jump_forward_else expr COME_FROM + expr ::= if_exp_not + if_exp_not ::= expr jmp_true expr jump_forward_else expr COME_FROM # a JUMP_FORWARD to another JUMP_FORWARD can get turned into # a JUMP_ABSOLUTE with no COME_FROM - conditional ::= expr jmp_false expr jump_absolute_else expr + if_exp ::= expr jmp_false expr jump_absolute_else expr - # if_expr_true are for conditions which always evaluate true + # if_exp_true are for conditions which always evaluate true # There is dead or non-optional remnants of the condition code though, # and we use that to match on to reconstruct the source more accurately - expr ::= if_expr_true - if_expr_true ::= expr JUMP_FORWARD expr COME_FROM + expr ::= if_exp_true + if_exp_true ::= expr JUMP_FORWARD expr COME_FROM """ def p_generator_exp3(self, args): @@ -967,15 +967,15 @@ class Python37Parser(Python37BaseParser): def p_stmt3(self, args): """ - stmt ::= if_expr_lambda - stmt ::= conditional_not_lambda + stmt ::= if_exp_lambda + stmt ::= if_exp_not_lambda # If statement inside a loop: stmt ::= ifstmtl - if_expr_lambda ::= expr jmp_false expr return_if_lambda + if_exp_lambda ::= expr jmp_false expr return_if_lambda return_stmt_lambda LAMBDA_MARKER - conditional_not_lambda + if_exp_not_lambda ::= expr jmp_true expr return_if_lambda return_stmt_lambda LAMBDA_MARKER @@ -1092,7 +1092,7 @@ class Python37Parser(Python37BaseParser): jf_cf ::= JUMP_FORWARD COME_FROM cf_jf_else ::= come_froms JUMP_FORWARD ELSE - conditional ::= expr jmp_false expr jf_cf expr COME_FROM + if_exp ::= expr jmp_false expr jf_cf expr COME_FROM async_for_stmt ::= setup_loop expr GET_AITER diff --git a/uncompyle6/parsers/parse37base.py b/uncompyle6/parsers/parse37base.py index ce287601..603c770b 100644 --- a/uncompyle6/parsers/parse37base.py +++ b/uncompyle6/parsers/parse37base.py @@ -159,12 +159,11 @@ class Python37BaseParser(PythonParser): stmt ::= assign2_pypy assign3_pypy ::= expr expr expr store store store assign2_pypy ::= expr expr store store - stmt ::= if_expr_lambda - stmt ::= conditional_not_lambda - if_expr_lambda ::= expr jmp_false expr return_if_lambda + stmt ::= if_exp_lambda + stmt ::= if_exp_not_lambda + if_exp_lambda ::= expr jmp_false expr return_if_lambda return_lambda LAMBDA_MARKER - conditional_not_lambda - ::= expr jmp_true expr return_if_lambda + if_exp_not_lambda ::= expr jmp_true expr return_if_lambda return_lambda LAMBDA_MARKER """, nop_func, diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index 21282468..13bfa5f0 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -56,11 +56,11 @@ PRECEDENCE = { '_mklambda': 30, - 'conditional': 28, # Conditional expression - 'conditional_lamdba': 28, # Lambda expression - 'conditional_not_lamdba': 28, # Lambda expression - 'conditionalnot': 28, - 'if_expr_true': 28, + 'if_exp': 28, # If_Exp expression + 'if_exp_lamdba': 28, # Lambda expression + 'if_exp_not_lamdba': 28, # Lambda expression + 'if_exp_not': 28, + 'if_exp_true': 28, 'ret_cond': 28, 'or': 26, # Boolean OR @@ -301,24 +301,24 @@ TABLE_DIRECT = { # which we don't use here. 'aug_assign1': ( '%|%c %c %c\n', 0, 2, 1), - 'aug_assign2': ( '%|%c.%[2]{pattr} %c %c\n', 0, -3, -4 ), - 'designList': ( '%c = %c', 0, -1 ), + 'aug_assign2': ( '%|%c.%[2]{pattr} %c %c\n', 0, -3, -4 ), + 'designList': ( '%c = %c', 0, -1 ), 'and': ( '%c and %c', 0, 2 ), 'ret_and': ( '%c and %c', 0, 2 ), 'and2': ( '%c', 3 ), 'or': ( '%c or %c', 0, 2 ), 'ret_or': ( '%c or %c', 0, 2 ), - 'conditional': ( '%p if %c else %c', + 'if_exp': ( '%p if %c else %c', (2, 'expr', 27), 0, 4 ), - 'if_expr_lambda': ( '%p if %c else %c', + 'if_exp_lambda': ( '%p if %c else %c', (2, 'expr', 27), (0, 'expr'), 4 ), - 'if_expr_true': ( '%p if 1 else %c', (0, 'expr', 27), 2 ), + 'if_exp_true': ( '%p if 1 else %c', (0, 'expr', 27), 2 ), 'ret_cond': ( '%p if %p else %p', (2, 27), (0, 27), (-1, 27) ), - 'conditional_not': ( '%p if not %p else %p', + 'if_exp_not': ( '%p if not %p else %p', (2, 27), (0, "expr", PRECEDENCE['unary_not']), (4, 27) ), - 'conditional_not_lambda': + 'if_exp_not_lambda': ( '%p if not %c else %c', (2, 'expr', 27), 0, 4 ), diff --git a/uncompyle6/semantics/customize3.py b/uncompyle6/semantics/customize3.py index 2393e8da..f1394fd3 100644 --- a/uncompyle6/semantics/customize3.py +++ b/uncompyle6/semantics/customize3.py @@ -36,7 +36,7 @@ def customize_for_version3(self, version): TABLE_DIRECT.update( { "comp_for": (" for %c in %c", (2, "store"), (0, "expr")), - "conditionalnot": ( + "if_exp_not": ( "%c if not %c else %c", (2, "expr"), (0, "expr"), diff --git a/uncompyle6/semantics/customize36.py b/uncompyle6/semantics/customize36.py index cc123a66..518671e3 100644 --- a/uncompyle6/semantics/customize36.py +++ b/uncompyle6/semantics/customize36.py @@ -64,7 +64,7 @@ def customize_for_version36(self, version): "call_ex": ("%c(%p)", (0, "expr"), (1, 100)), # This comes from 3.7. Eventually we will rebase from 3.7 # and then this can go away - "conditional37": ("%p if %c else %c", (1, "expr", 27), 0, 3), + "if_exp37": ("%p if %c else %c", (1, "expr", 27), 0, 3), "store_annotation": ("%[1]{pattr}: %c", 0), "ann_assign_init_value": ( "%|%c = %p\n", diff --git a/uncompyle6/semantics/customize37.py b/uncompyle6/semantics/customize37.py index 4a934d5a..f9892058 100644 --- a/uncompyle6/semantics/customize37.py +++ b/uncompyle6/semantics/customize37.py @@ -115,8 +115,8 @@ def customize_for_version37(self, version): (0, 19), (6, 19), ), - 'conditional37': ( '%p if %c else %c', - (1, 'expr', 27), 0, 3 ), + 'if_exp37': ( '%p if %c else %c', + (1, 'expr', 27), 0, 3 ), "except_return": ("%|except:\n%+%c%-", 3), "if_exp_37a": ( diff --git a/uncompyle6/semantics/helper.py b/uncompyle6/semantics/helper.py index 3b048936..279e234e 100644 --- a/uncompyle6/semantics/helper.py +++ b/uncompyle6/semantics/helper.py @@ -51,7 +51,7 @@ def find_all_globals(node, globs): # # print("XXX", n.kind, global_ops) # if isinstance(n, SyntaxTree): # # FIXME: do I need a caser for n.kind="mkfunc"? -# if n.kind in ("if_expr_lambda", "return_lambda"): +# if n.kind in ("if_exp_lambda", "return_lambda"): # globs = find_globals(n, globs, mklambda_globals) # else: # globs = find_globals(n, globs, global_ops)