Skip to content

Commit 4e6e383

Browse files
committed
3.x list comprehenions list_if_not, comp_ifnot bug
Saw only list_if_not bug, but might also be applicable to comp_ifnot
1 parent fb870cc commit 4e6e383

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

README.rst

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,14 @@ for usage help.
8484
Known Bugs/Restrictions
8585
-----------------------
8686

87-
Python 2 deparsing decompiles each and all the Python 2.3 to 2.7.10
88-
installed packages I have on my system. Later distributions average
89-
about 200 files.
90-
91-
More than 90% of the 2.7 files verify ok Some of these failures may be
92-
bugs in the verification process. At this point, 2.7 decompilation is
93-
better than uncompyle2. A number of bugs have been fixed over what was
94-
in uncompyle2.
95-
96-
That said, I'd like the decompilation process still feels a little bit
97-
hacky in certain places and we still get parse errors too often.
87+
Python 2 deparsing decompiles and verifies each and all the Python 2.6.9
88+
to 2.7.11 installed packages I have on my system. Later distributions
89+
average about 200 files. At this point, 2.7 decompilation is
90+
better than uncompyle2. A number of bugs have been fixed.
91+
92+
For Python 3.4.2 bytecode, there is one verification error that needs
93+
addressing. There are still a couple of parse errors on 2.3.7 and
94+
2.4.6. Removing 3.5 verification errors still remains.
9895

9996
There are a few constructs that still need to be added to Python 3.5.
10097
Python 3.6 changes things drastically by using word codes rather than
290 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

uncompyle6/semantics/fragments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,13 +669,15 @@ def comprehension_walk3(self, node, iter_index, code_index=-5):
669669
comp_for = n
670670
comp_designator = ast[3]
671671

672+
have_not = False
672673
while n in ('list_iter', 'comp_iter'):
673674
n = n[0] # recurse one step
674675
if n == 'list_for':
675676
if n[2] == 'designator':
676677
designator = n[2]
677678
n = n[3]
678679
elif n in ['list_if', 'list_if_not', 'comp_if']:
680+
have_not = n in ('list_if_not', 'comp_ifnot')
679681
if_node = n[0]
680682
if n[1] == 'designator':
681683
designator = n[1]
@@ -707,6 +709,8 @@ def comprehension_walk3(self, node, iter_index, code_index=-5):
707709
self.preorder(comp_for)
708710
elif if_node:
709711
self.write(' if ')
712+
if have_not:
713+
self.write('not ')
710714
self.preorder(if_node)
711715
self.prec = p
712716
self.name = old_name

uncompyle6/semantics/pysource.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,13 +1171,15 @@ def comprehension_walk3(self, node, iter_index, code_index=-5):
11711171
comp_for = n
11721172
comp_designator = ast[3]
11731173

1174+
have_not = False
11741175
while n in ('list_iter', 'comp_iter'):
11751176
n = n[0] # recurse one step
11761177
if n in ('list_for', 'comp_for'):
11771178
if n[2] == 'designator':
11781179
designator = n[2]
11791180
n = n[3]
1180-
elif n in ('list_if', 'list_if_not', 'comp_if'):
1181+
elif n in ('list_if', 'list_if_not', 'comp_if', 'comp_ifnot'):
1182+
have_not = n in ('list_if_not', 'comp_ifnot')
11811183
if_node = n[0]
11821184
if n[1] == 'designator':
11831185
designator = n[1]
@@ -1203,6 +1205,8 @@ def comprehension_walk3(self, node, iter_index, code_index=-5):
12031205
self.preorder(comp_for)
12041206
elif if_node:
12051207
self.write(' if ')
1208+
if have_not:
1209+
self.write('not ')
12061210
self.preorder(if_node)
12071211
self.prec = p
12081212

0 commit comments

Comments
 (0)