3.x list comprehenions list_if_not, comp_ifnot bug

Saw only list_if_not bug, but might also be applicable
to comp_ifnot
This commit is contained in:
rocky 2016-07-14 11:26:02 -04:00
parent fb870ccd8d
commit 4e6e38358d
5 changed files with 16 additions and 11 deletions

View File

@ -84,17 +84,14 @@ for usage help.
Known Bugs/Restrictions
-----------------------
Python 2 deparsing decompiles each and all the Python 2.3 to 2.7.10
installed packages I have on my system. Later distributions average
about 200 files.
Python 2 deparsing decompiles and verifies each and all the Python 2.6.9
to 2.7.11 installed packages I have on my system. Later distributions
average about 200 files. At this point, 2.7 decompilation is
better than uncompyle2. A number of bugs have been fixed.
More than 90% of the 2.7 files verify ok Some of these failures may be
bugs in the verification process. At this point, 2.7 decompilation is
better than uncompyle2. A number of bugs have been fixed over what was
in uncompyle2.
That said, I'd like the decompilation process still feels a little bit
hacky in certain places and we still get parse errors too often.
For Python 3.4.2 bytecode, there is one verification error that needs
addressing. There are still a couple of parse errors on 2.3.7 and
2.4.6. Removing 3.5 verification errors still remains.
There are a few constructs that still need to be added to Python 3.5.
Python 3.6 changes things drastically by using word codes rather than

Binary file not shown.

Binary file not shown.

View File

@ -669,6 +669,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
comp_for = n
comp_designator = ast[3]
have_not = False
while n in ('list_iter', 'comp_iter'):
n = n[0] # recurse one step
if n == 'list_for':
@ -676,6 +677,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
designator = n[2]
n = n[3]
elif n in ['list_if', 'list_if_not', 'comp_if']:
have_not = n in ('list_if_not', 'comp_ifnot')
if_node = n[0]
if n[1] == 'designator':
designator = n[1]
@ -707,6 +709,8 @@ class FragmentsWalker(pysource.SourceWalker, object):
self.preorder(comp_for)
elif if_node:
self.write(' if ')
if have_not:
self.write('not ')
self.preorder(if_node)
self.prec = p
self.name = old_name

View File

@ -1171,13 +1171,15 @@ class SourceWalker(GenericASTTraversal, object):
comp_for = n
comp_designator = ast[3]
have_not = False
while n in ('list_iter', 'comp_iter'):
n = n[0] # recurse one step
if n in ('list_for', 'comp_for'):
if n[2] == 'designator':
designator = n[2]
n = n[3]
elif n in ('list_if', 'list_if_not', 'comp_if'):
elif n in ('list_if', 'list_if_not', 'comp_if', 'comp_ifnot'):
have_not = n in ('list_if_not', 'comp_ifnot')
if_node = n[0]
if n[1] == 'designator':
designator = n[1]
@ -1203,6 +1205,8 @@ class SourceWalker(GenericASTTraversal, object):
self.preorder(comp_for)
elif if_node:
self.write(' if ')
if have_not:
self.write('not ')
self.preorder(if_node)
self.prec = p