Skip to content

Commit

Permalink
Improve 3.4 ifelse inside a lambda
Browse files Browse the repository at this point in the history
Fixes #426
  • Loading branch information
rocky committed Jul 14, 2024
1 parent 389fc23 commit 02b0805
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 1 deletion.
Binary file added test/bytecode_3.3/03_ifelse_in_lambda.pyc
Binary file not shown.
Binary file added test/bytecode_3.4/03_ifelse_in_lambda.pyc
Binary file not shown.
Binary file added test/bytecode_3.5/03_ifelse_in_lambda.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions test/simple_source/bug34/03_ifelse_in_lambda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Next line is 1164
def foo():
name = "bar"
lambda x: compile(x, "<register %s's commit>" % name, "exec") if x else None
4 changes: 4 additions & 0 deletions uncompyle6/parsers/parse34.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def p_misc34(self, args):
_ifstmts_jump ::= c_stmts_opt JUMP_ABSOLUTE JUMP_FORWARD COME_FROM
genexpr_func ::= LOAD_ARG _come_froms FOR_ITER store comp_iter JUMP_BACK
if_exp_lambda ::= expr jmp_false expr return_if_lambda come_froms return_stmt_lambda LAMBDA_MARKER
return_if_stmt ::= return_expr RETURN_END_IF POP_BLOCK
"""

def customize_grammar_rules(self, tokens, customize):
Expand Down
1 change: 0 additions & 1 deletion uncompyle6/parsers/parse35.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def p_35on(self, args):
# Python 3.5+ does jump optimization
# In <.3.5 the below is a JUMP_FORWARD to a JUMP_ABSOLUTE.
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
Expand Down

0 comments on commit 02b0805

Please sign in to comment.