From 5951f974d5d7e0754a2f12614497ff8004b8b248 Mon Sep 17 00:00:00 2001 From: rocky Date: Thu, 23 Jan 2020 06:07:34 -0500 Subject: [PATCH] Fix 3.8 grammar rule bug: "for" with "if"/"return" --- .../04_for_no_jump_back.pyc-notyet | Bin 446 -> 0 bytes test/simple_source/bug38/04_for_no_jump_back.py | 2 ++ uncompyle6/parsers/parse38.py | 2 +- uncompyle6/semantics/consts.py | 16 ++++++++-------- 4 files changed, 11 insertions(+), 9 deletions(-) delete mode 100644 test/bytecode_3.8_run/04_for_no_jump_back.pyc-notyet diff --git a/test/bytecode_3.8_run/04_for_no_jump_back.pyc-notyet b/test/bytecode_3.8_run/04_for_no_jump_back.pyc-notyet deleted file mode 100644 index fb7672f97d6ab5877a0db2df80042dd0bbe31301..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 446 zcmY+9zfQw25XSFpCygq#140NPCblwA1Plxaf%qe)E`_C1v6|RarESvMF%nX{058KU zWo7EZ12Az;L6o!ZlkaEyzVltJRs{+kes%=|`0&MQ2rAAfZA_v-;Tv>7Lmw1V?3F7% zWOh5p7u2A5AAhJIday!+@@`1<<{u5HLqPQ2Q&nk0BT6_K{f2j^so;Xr?vTvj61tmn zK0~vnaE?OW^jxHow&w#vsY$p={~t)4oaCR#rAMo#-tZQYw< zgaX4d88a0kw+kdSUapP*Pph#!DC+0dYUA5o8Izg6v6egkks>-7XUdKAX=xD=imL0l GLF*eNI$b6J diff --git a/test/simple_source/bug38/04_for_no_jump_back.py b/test/simple_source/bug38/04_for_no_jump_back.py index 84d425dc..e20df54b 100644 --- a/test/simple_source/bug38/04_for_no_jump_back.py +++ b/test/simple_source/bug38/04_for_no_jump_back.py @@ -1,6 +1,8 @@ # from mult_by_const/instruction.py # Bug in 3.8 was handling no JUMP_BACK in "for" loop. It is # in the "if" instead + +# RUNNABLE! def instruction_sequence_value(instrs, a, b): for instr in instrs: if a: diff --git a/uncompyle6/parsers/parse38.py b/uncompyle6/parsers/parse38.py index a8d7efad..1ccd1475 100644 --- a/uncompyle6/parsers/parse38.py +++ b/uncompyle6/parsers/parse38.py @@ -85,7 +85,7 @@ class Python38Parser(Python37Parser): # 3.8 can push a looping JUMP_BACK into into a JUMP_ from a statement that jumps to it lastl_stmt ::= ifpoplaststmtl - ifpoplaststmtl ::= testexpr POP_TOP c_stmts_opt JUMP_BACK + ifpoplaststmtl ::= testexpr POP_TOP c_stmts_opt ifelsestmtl ::= testexpr c_stmts_opt jb_cfs else_suitel JUMP_BACK come_froms # Keep indices the same in ifelsestmtl diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index 566c0997..ed317636 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -471,19 +471,19 @@ MAP_R0 = (TABLE_R0, -1, 0) MAP_R = (TABLE_R, -1) MAP = { - 'stmt': MAP_R, - 'call': MAP_R, - 'del_stmt': MAP_R, - 'store': MAP_R, - 'exprlist': MAP_R0, + "stmt": MAP_R, + "call": MAP_R, + "del_stmt": MAP_R, + "store": MAP_R, + "exprlist": MAP_R0, } ASSIGN_TUPLE_PARAM = lambda param_name: \ - SyntaxTree('expr', [ Token('LOAD_FAST', pattr=param_name) ]) + SyntaxTree("expr", [ Token("LOAD_FAST", pattr=param_name) ]) -escape = re.compile(r''' +escape = re.compile(r""" (?P [^%]* ) % ( \[ (?P -? \d+ ) \] )? ((?P [^{] ) | ( [{] (?P [^}]* ) [}] )) - ''', re.VERBOSE) + """, re.VERBOSE)