From 7787166ddfaf8d849d1d9312d3ad7135aceacb3b Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 13 Jul 2024 15:57:24 -0400 Subject: [PATCH] Add grammar rule involving RETURN_END_IF --- test/bytecode_3.5/02_for_else_bug.pyc | Bin 0 -> 301 bytes test/simple_source/bug35/02_for_else_bug.py | 10 ++++++++++ uncompyle6/parsers/parse35.py | 2 ++ uncompyle6/semantics/consts.py | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/bytecode_3.5/02_for_else_bug.pyc create mode 100644 test/simple_source/bug35/02_for_else_bug.py diff --git a/test/bytecode_3.5/02_for_else_bug.pyc b/test/bytecode_3.5/02_for_else_bug.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ace423162f9be783d1773c539ef26c88162d7ad7 GIT binary patch literal 301 zcmYk0!Ait16h&`Zr&9(3?gqCm2D))XaVH|^T7+2)2olCNm11gYG6jWk=NI@F{!+Gn zgBw@gR7QN{+`Q!F-Mp!klZUVOIso`2e~~adCw`YwaS6NuH%t;NinNUN7%7SQ1@SY= z25|d$-oqNWyp?!Oun}+)*H02lIxQlFxGF@*m8u(~l`7JZ8M~^q3%Rl7YTek!Ak+uk zh?d_o-?SaydE2{E&+q#CPD->ub79Bx8^$b=-L b#Ep6448uPB@=r3>LVnuXsyF&<=#I@lP;o$h literal 0 HcmV?d00001 diff --git a/test/simple_source/bug35/02_for_else_bug.py b/test/simple_source/bug35/02_for_else_bug.py new file mode 100644 index 00000000..c8f85ad8 --- /dev/null +++ b/test/simple_source/bug35/02_for_else_bug.py @@ -0,0 +1,10 @@ +# Adapted 3.5 from _bootstrap_external.py + + +def spec_from_file_location(loader, location): + if loader: + for _ in __file__: + if location: + break + else: + return None diff --git a/uncompyle6/parsers/parse35.py b/uncompyle6/parsers/parse35.py index fd2bd5cc..e5bc9b10 100644 --- a/uncompyle6/parsers/parse35.py +++ b/uncompyle6/parsers/parse35.py @@ -111,6 +111,8 @@ class Python35Parser(Python34Parser): return_if_stmt ::= return_expr RETURN_END_IF POP_BLOCK return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM + return ::= return_expr RETURN_END_IF + jb_else ::= JUMP_BACK ELSE ifelsestmtc ::= testexpr c_stmts_opt JUMP_FORWARD else_suitec ifelsestmtl ::= testexpr c_stmts_opt jb_else else_suitel diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index 7b9cd7d1..7ea9967b 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -431,7 +431,7 @@ TABLE_DIRECT = { "mkfuncdeco": ("%|@%c\n%c", (0, "expr"), 1), # A custom rule in n_function def distinguishes whether to call this or # function_def_async - "mkfuncdeco0": ("%|def %c\n", (0, "mkfunc")), + "mkfuncdeco0": ("%|def %c\n", (0, ("mkfunc", "mkfunc_annotate"))), # In cases where we desire an explict new line. # After docstrings which are followed by a "def" is