diff --git a/test/bytecode_2.7_run/03_comprehension_in_lambda.pyc b/test/bytecode_2.7_run/03_comprehension_in_lambda.pyc new file mode 100644 index 00000000..e7b3586a Binary files /dev/null and b/test/bytecode_2.7_run/03_comprehension_in_lambda.pyc differ diff --git a/test/bytecode_3.7_run/03_comprehension_in_lambda.pyc b/test/bytecode_3.7_run/03_comprehension_in_lambda.pyc new file mode 100644 index 00000000..7a80bf5c Binary files /dev/null and b/test/bytecode_3.7_run/03_comprehension_in_lambda.pyc differ diff --git a/test/bytecode_3.8_run/03_comprehension_in_lambda.pyc b/test/bytecode_3.8_run/03_comprehension_in_lambda.pyc new file mode 100644 index 00000000..76233c0e Binary files /dev/null and b/test/bytecode_3.8_run/03_comprehension_in_lambda.pyc differ diff --git a/test/simple_source/bug27+/03_comprehension_in_lambda.py b/test/simple_source/bug27+/03_comprehension_in_lambda.py new file mode 100644 index 00000000..6928575d --- /dev/null +++ b/test/simple_source/bug27+/03_comprehension_in_lambda.py @@ -0,0 +1,11 @@ +# RUNNABLE! +# From issue 469 + +"""This program is self-checking!""" + +my_dict = (lambda variable0: {variable1: 123 for variable1 in variable0})([1, 2, 3]) + +assert my_dict[1] == 123 + +my_set = (lambda variable0: {variable1 for variable1 in variable0})([1, 2, 3]) +assert 2 in my_set diff --git a/uncompyle6/parsers/parse27.py b/uncompyle6/parsers/parse27.py index 92f0d4b6..06498caa 100644 --- a/uncompyle6/parsers/parse27.py +++ b/uncompyle6/parsers/parse27.py @@ -37,11 +37,16 @@ class Python27Parser(Python2Parser): dict_comp ::= LOAD_DICTCOMP MAKE_FUNCTION_0 expr GET_ITER CALL_FUNCTION_1 stmt ::= dict_comp_func + dict_comp_func ::= BUILD_MAP_0 LOAD_FAST FOR_ITER store comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST + dict_comp_func ::= BUILD_MAP_0 LOAD_FAST FOR_ITER store + comp_iter JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST + set_comp_func ::= BUILD_SET_0 LOAD_FAST FOR_ITER store comp_iter + JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER comp_iter ::= comp_if_not comp_if_not ::= expr jmp_true comp_iter diff --git a/uncompyle6/parsers/parse30.py b/uncompyle6/parsers/parse30.py index f9106665..f1d2546c 100644 --- a/uncompyle6/parsers/parse30.py +++ b/uncompyle6/parsers/parse30.py @@ -74,9 +74,15 @@ class Python30Parser(Python31Parser): # Need to keep LOAD_FAST as index 1 set_comp_header ::= BUILD_SET_0 DUP_TOP STORE_FAST + set_comp_func ::= set_comp_header LOAD_ARG FOR_ITER store comp_iter - JUMP_BACK COME_FROM POP_TOP JUMP_BACK RETURN_VALUE RETURN_LAST + JUMP_BACK COME_FROM POP_TOP JUMP_BACK + RETURN_VALUE RETURN_LAST + set_comp_func ::= set_comp_header + LOAD_ARG FOR_ITER store comp_iter + JUMP_BACK COME_FROM POP_TOP JUMP_BACK + RETURN_VALUE_LAMBDA LAMBDA_MARKER list_comp_header ::= BUILD_LIST_0 DUP_TOP STORE_FAST list_comp ::= list_comp_header @@ -107,6 +113,10 @@ class Python30Parser(Python31Parser): DUP_TOP STORE_FAST LOAD_ARG FOR_ITER store dict_comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST + dict_comp_func ::= BUILD_MAP_0 + DUP_TOP STORE_FAST + LOAD_ARG FOR_ITER store + dict_comp_iter JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER stmt ::= try_except30 try_except30 ::= SETUP_EXCEPT suite_stmts_opt diff --git a/uncompyle6/parsers/parse37.py b/uncompyle6/parsers/parse37.py index fad4d1ce..ad2e6248 100644 --- a/uncompyle6/parsers/parse37.py +++ b/uncompyle6/parsers/parse37.py @@ -741,9 +741,13 @@ class Python37Parser(Python37BaseParser): set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST + set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter + JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter COME_FROM JUMP_BACK RETURN_VALUE RETURN_LAST + set_comp_func ::= BUILD_SET_0 LOAD_ARG for_iter store comp_iter + COME_FROM JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER comp_body ::= dict_comp_body comp_body ::= set_comp_body @@ -757,8 +761,11 @@ class Python37Parser(Python37BaseParser): """" expr ::= dict_comp stmt ::= dict_comp_func + dict_comp_func ::= BUILD_MAP_0 LOAD_ARG for_iter store comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST + dict_comp_func ::= BUILD_MAP_0 LOAD_ARG for_iter store + comp_iter JUMP_BACK RETURN_VALUE_LAMBDA LAMBDA_MARKER comp_iter ::= comp_if comp_iter ::= comp_if_not