You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Improve set comprehension for Python 3.0
This commit is contained in:
@@ -74,8 +74,8 @@ 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_FAST FOR_ITER store comp_iter
|
||||
JUMP_BACK POP_TOP JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
LOAD_ARG FOR_ITER store comp_iter
|
||||
JUMP_BACK COME_FROM POP_TOP JUMP_BACK RETURN_VALUE RETURN_LAST
|
||||
|
||||
list_comp_header ::= BUILD_LIST_0 DUP_TOP STORE_FAST
|
||||
list_comp ::= list_comp_header
|
||||
|
@@ -465,7 +465,7 @@ class ComprehensionMixin:
|
||||
self.write(": ")
|
||||
self.preorder(n[1])
|
||||
else:
|
||||
if self.version == (3, 0):
|
||||
if self.version == (3, 0) and len(n) > 1:
|
||||
body = n[1]
|
||||
else:
|
||||
body = n[0]
|
||||
|
@@ -1093,7 +1093,12 @@ class NonterminalActions:
|
||||
self.write("{")
|
||||
if node[0] in ["LOAD_SETCOMP", "LOAD_DICTCOMP"]:
|
||||
if self.version == (3, 0):
|
||||
iter_index = 6
|
||||
if len(node) >= 6:
|
||||
iter_index = 6
|
||||
else:
|
||||
assert node[1].kind.startswith("MAKE_FUNCTION")
|
||||
iter_index = 2
|
||||
pass
|
||||
else:
|
||||
iter_index = 1
|
||||
self.comprehension_walk_newer(node, iter_index=iter_index, code_index=0)
|
||||
|
Reference in New Issue
Block a user