mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-12-03 18:41:03 +00:00
Merge pull request #470 from rocky/comprehension-in-lambda-parsing-bug
Handle comprehensions inside a lambda
This commit is contained in:
commit
9a14d2dea8
BIN
test/bytecode_2.7_run/03_comprehension_in_lambda.pyc
Normal file
BIN
test/bytecode_2.7_run/03_comprehension_in_lambda.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.7_run/03_comprehension_in_lambda.pyc
Normal file
BIN
test/bytecode_3.7_run/03_comprehension_in_lambda.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.8_run/03_comprehension_in_lambda.pyc
Normal file
BIN
test/bytecode_3.8_run/03_comprehension_in_lambda.pyc
Normal file
Binary file not shown.
11
test/simple_source/bug27+/03_comprehension_in_lambda.py
Normal file
11
test/simple_source/bug27+/03_comprehension_in_lambda.py
Normal file
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user