You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
BIN
test/bytecode_3.1/05_dict_comp.pyc
Normal file
BIN
test/bytecode_3.1/05_dict_comp.pyc
Normal file
Binary file not shown.
6
test/simple_source/comprehension/05_dict_comp.py
Normal file
6
test/simple_source/comprehension/05_dict_comp.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# Issue #162
|
||||
def x(s):
|
||||
return {k: v
|
||||
for (k, v) in s
|
||||
if not k.startswith('_')
|
||||
}
|
@@ -74,6 +74,11 @@ class Python3Parser(PythonParser):
|
||||
comp_iter JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
dict_comp ::= LOAD_DICTCOMP LOAD_CONST MAKE_FUNCTION_0 expr
|
||||
GET_ITER CALL_FUNCTION_1
|
||||
|
||||
comp_iter ::= comp_if
|
||||
comp_iter ::= comp_if_not
|
||||
comp_if_not ::= expr jmp_true comp_iter
|
||||
comp_iter ::= comp_body
|
||||
"""
|
||||
|
||||
def p_grammar(self, args):
|
||||
|
@@ -184,7 +184,7 @@ TABLE_DIRECT = {
|
||||
|
||||
'comp_iter': ( '%c', 0 ),
|
||||
'comp_if': ( ' if %c%c', 0, 2 ),
|
||||
'comp_ifnot': ( ' if not %p%c', (0, 22), 2 ),
|
||||
'comp_if_not': ( ' if not %p%c', (0, 22), 2 ),
|
||||
'comp_body': ( '', ), # ignore when recusing
|
||||
'set_comp_body': ( '%c', 0 ),
|
||||
'gen_comp_body': ( '%c', 0 ),
|
||||
|
@@ -1327,8 +1327,8 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
if n[2] == 'store':
|
||||
store = n[2]
|
||||
n = n[3]
|
||||
elif n in ('list_if', 'list_if_not', 'comp_if', 'comp_ifnot'):
|
||||
have_not = n in ('list_if_not', 'comp_ifnot')
|
||||
elif n in ('list_if', 'list_if_not', 'comp_if', 'comp_if_not'):
|
||||
have_not = n in ('list_if_not', 'comp_if_not')
|
||||
if_node = n[0]
|
||||
if n[1] == 'store':
|
||||
store = n[1]
|
||||
|
Reference in New Issue
Block a user