Skip to content

Commit 04da2fb

Browse files
committed
Improve 3.4 ifelse inside a lambda
Fixes #426
1 parent 389fc23 commit 04da2fb

File tree

6 files changed

+8
-1
lines changed

6 files changed

+8
-1
lines changed
577 Bytes
Binary file not shown.
414 Bytes
Binary file not shown.
414 Bytes
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Next line is 1164
2+
def foo():
3+
name = "bar"
4+
lambda x: compile(x, "<register %s's commit>" % name, "exec") if x else None

uncompyle6/parsers/parse34.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ def p_misc34(self, args):
5353
_ifstmts_jump ::= c_stmts_opt JUMP_ABSOLUTE JUMP_FORWARD COME_FROM
5454
5555
genexpr_func ::= LOAD_ARG _come_froms FOR_ITER store comp_iter JUMP_BACK
56+
57+
if_exp_lambda ::= expr jmp_false expr return_if_lambda return_stmt_lambda LAMBDA_MARKER
58+
return_if_lambda ::= RETURN_END_IF_LAMBDA come_froms
59+
return_if_stmt ::= return_expr RETURN_END_IF POP_BLOCK
5660
"""
5761

5862
def customize_grammar_rules(self, tokens, customize):

uncompyle6/parsers/parse35.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ def p_35on(self, args):
108108
# Python 3.5+ does jump optimization
109109
# In <.3.5 the below is a JUMP_FORWARD to a JUMP_ABSOLUTE.
110110
111-
return_if_stmt ::= return_expr RETURN_END_IF POP_BLOCK
112111
return_if_lambda ::= RETURN_END_IF_LAMBDA COME_FROM
113112
114113
return ::= return_expr RETURN_END_IF

0 commit comments

Comments
 (0)