mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-02-18 20:29:14 +00:00
3.0 list comprehensions
This commit is contained in:
parent
67910e7d8e
commit
0353b74a7a
BIN
test/bytecode_3.0/01_comprehension.pyc
Normal file
BIN
test/bytecode_3.0/01_comprehension.pyc
Normal file
Binary file not shown.
@ -43,8 +43,16 @@ class Python30Parser(Python31Parser):
|
||||
set_comp_func ::= set_comp_func_header
|
||||
LOAD_FAST FOR_ITER store comp_iter
|
||||
JUMP_BACK POP_TOP JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
|
||||
list_comp_header ::= BUILD_LIST_0 DUP_TOP STORE_FAST
|
||||
list_comp ::= list_comp_header
|
||||
LOAD_FAST FOR_ITER store comp_iter
|
||||
JUMP_BACK
|
||||
|
||||
|
||||
comp_if ::= expr jmp_false comp_iter
|
||||
comp_iter ::= expr expr SET_ADD
|
||||
comp_iter ::= expr expr LIST_APPEND
|
||||
|
||||
# In many ways 3.0 is like 2.6. The below rules in fact are the same or similar.
|
||||
|
||||
|
@ -1052,7 +1052,8 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
ast = ast[0]
|
||||
|
||||
store = None
|
||||
if ast in ['set_comp_func', 'dict_comp_func', 'set_comp_func_header']:
|
||||
if ast in ['set_comp_func', 'dict_comp_func',
|
||||
'list_comp', 'set_comp_func_header']:
|
||||
for k in ast:
|
||||
if k == 'comp_iter':
|
||||
n = k
|
||||
@ -1125,7 +1126,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.write(' in ')
|
||||
self.preorder(node[-3])
|
||||
|
||||
if ast == 'list_comp':
|
||||
if ast == 'list_comp' and self.version != 3.0:
|
||||
list_iter = ast[1]
|
||||
assert list_iter == 'list_iter'
|
||||
if list_iter == 'list_for':
|
||||
|
Loading…
x
Reference in New Issue
Block a user