mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-27 23:20:50 +00:00
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:
parent
fb870ccd8d
commit
4e6e38358d
17
README.rst
17
README.rst
@ -84,17 +84,14 @@ for usage help.
|
|||||||
Known Bugs/Restrictions
|
Known Bugs/Restrictions
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
Python 2 deparsing decompiles each and all the Python 2.3 to 2.7.10
|
Python 2 deparsing decompiles and verifies each and all the Python 2.6.9
|
||||||
installed packages I have on my system. Later distributions average
|
to 2.7.11 installed packages I have on my system. Later distributions
|
||||||
about 200 files.
|
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
|
For Python 3.4.2 bytecode, there is one verification error that needs
|
||||||
bugs in the verification process. At this point, 2.7 decompilation is
|
addressing. There are still a couple of parse errors on 2.3.7 and
|
||||||
better than uncompyle2. A number of bugs have been fixed over what was
|
2.4.6. Removing 3.5 verification errors still remains.
|
||||||
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.
|
|
||||||
|
|
||||||
There are a few constructs that still need to be added to Python 3.5.
|
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
|
Python 3.6 changes things drastically by using word codes rather than
|
||||||
|
BIN
test/bytecode_3.4/06_list_ifnot.pyc
Normal file
BIN
test/bytecode_3.4/06_list_ifnot.pyc
Normal file
Binary file not shown.
Binary file not shown.
@ -669,6 +669,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
comp_for = n
|
comp_for = n
|
||||||
comp_designator = ast[3]
|
comp_designator = ast[3]
|
||||||
|
|
||||||
|
have_not = False
|
||||||
while n in ('list_iter', 'comp_iter'):
|
while n in ('list_iter', 'comp_iter'):
|
||||||
n = n[0] # recurse one step
|
n = n[0] # recurse one step
|
||||||
if n == 'list_for':
|
if n == 'list_for':
|
||||||
@ -676,6 +677,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
designator = n[2]
|
designator = n[2]
|
||||||
n = n[3]
|
n = n[3]
|
||||||
elif n in ['list_if', 'list_if_not', 'comp_if']:
|
elif n in ['list_if', 'list_if_not', 'comp_if']:
|
||||||
|
have_not = n in ('list_if_not', 'comp_ifnot')
|
||||||
if_node = n[0]
|
if_node = n[0]
|
||||||
if n[1] == 'designator':
|
if n[1] == 'designator':
|
||||||
designator = n[1]
|
designator = n[1]
|
||||||
@ -707,6 +709,8 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
self.preorder(comp_for)
|
self.preorder(comp_for)
|
||||||
elif if_node:
|
elif if_node:
|
||||||
self.write(' if ')
|
self.write(' if ')
|
||||||
|
if have_not:
|
||||||
|
self.write('not ')
|
||||||
self.preorder(if_node)
|
self.preorder(if_node)
|
||||||
self.prec = p
|
self.prec = p
|
||||||
self.name = old_name
|
self.name = old_name
|
||||||
|
@ -1171,13 +1171,15 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
comp_for = n
|
comp_for = n
|
||||||
comp_designator = ast[3]
|
comp_designator = ast[3]
|
||||||
|
|
||||||
|
have_not = False
|
||||||
while n in ('list_iter', 'comp_iter'):
|
while n in ('list_iter', 'comp_iter'):
|
||||||
n = n[0] # recurse one step
|
n = n[0] # recurse one step
|
||||||
if n in ('list_for', 'comp_for'):
|
if n in ('list_for', 'comp_for'):
|
||||||
if n[2] == 'designator':
|
if n[2] == 'designator':
|
||||||
designator = n[2]
|
designator = n[2]
|
||||||
n = n[3]
|
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_node = n[0]
|
||||||
if n[1] == 'designator':
|
if n[1] == 'designator':
|
||||||
designator = n[1]
|
designator = n[1]
|
||||||
@ -1203,6 +1205,8 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
self.preorder(comp_for)
|
self.preorder(comp_for)
|
||||||
elif if_node:
|
elif if_node:
|
||||||
self.write(' if ')
|
self.write(' if ')
|
||||||
|
if have_not:
|
||||||
|
self.write('not ')
|
||||||
self.preorder(if_node)
|
self.preorder(if_node)
|
||||||
self.prec = p
|
self.prec = p
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user