You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Python 2.7 set comprehension bug
This commit is contained in:
@@ -1202,7 +1202,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.write('{')
|
||||
if node[0] in ['LOAD_SETCOMP', 'LOAD_DICTCOMP']:
|
||||
self.comprehension_walk3(node, 1, 0)
|
||||
elif node[0].type == 'load_closure':
|
||||
elif node[0].type == 'load_closure' and self.version >= 3.0:
|
||||
self.setcomprehension_walk3(node, collection_index=4)
|
||||
else:
|
||||
self.comprehension_walk(node, iter_index=4)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# (C) Copyright 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||
# (C) Copyright 2015 by Rocky Bernstein
|
||||
# (C) Copyright 2015-2016 by Rocky Bernstein
|
||||
#
|
||||
"""
|
||||
byte-code verification
|
||||
@@ -132,7 +132,7 @@ class CmpErrorMember(VerifyCmpError):
|
||||
# these members are ignored
|
||||
__IGNORE_CODE_MEMBERS__ = ['co_filename', 'co_firstlineno', 'co_lnotab', 'co_stacksize', 'co_names']
|
||||
|
||||
def cmp_code_objects(version, code_obj1, code_obj2, name='', is_pypy=False):
|
||||
def cmp_code_objects(version, is_pypy, code_obj1, code_obj2, name=''):
|
||||
"""
|
||||
Compare two code-objects.
|
||||
|
||||
@@ -195,7 +195,7 @@ def cmp_code_objects(version, code_obj1, code_obj2, name='', is_pypy=False):
|
||||
elif version == 2.7:
|
||||
if is_pypy:
|
||||
import uncompyle6.scanners.pypy27 as scan
|
||||
scanner = scan.ScannerPyPy27()
|
||||
scanner = scan.ScannerPyPy27(show_asm=False)
|
||||
else:
|
||||
import uncompyle6.scanners.scanner27 as scan
|
||||
scanner = scan.Scanner27()
|
||||
@@ -331,7 +331,7 @@ def cmp_code_objects(version, code_obj1, code_obj2, name='', is_pypy=False):
|
||||
codes2 = ( c for c in code_obj2.co_consts if hasattr(c, 'co_consts') )
|
||||
|
||||
for c1, c2 in zip(codes1, codes2):
|
||||
cmp_code_objects(version, c1, c2, name=name)
|
||||
cmp_code_objects(version, is_pypy, c1, c2, name=name)
|
||||
else:
|
||||
# all other members must be equal
|
||||
if getattr(code_obj1, member) != getattr(code_obj2, member):
|
||||
@@ -373,14 +373,14 @@ def compare_code_with_srcfile(pyc_filename, src_filename):
|
||||
% (PYTHON_MAGIC_INT, magic_int))
|
||||
return msg
|
||||
code_obj2 = load_file(src_filename)
|
||||
cmp_code_objects(version, code_obj1, code_obj2)
|
||||
cmp_code_objects(version, is_pypy, code_obj1, code_obj2)
|
||||
return None
|
||||
|
||||
def compare_files(pyc_filename1, pyc_filename2):
|
||||
"""Compare two .pyc files."""
|
||||
version, timestamp, magic_int1, code_obj1, is_pypy = uncompyle6.load_module(pyc_filename1)
|
||||
version, timestamp, magic_int2, code_obj2, is_pypy = uncompyle6.load_module(pyc_filename2)
|
||||
cmp_code_objects(version, code_obj1, code_obj2)
|
||||
cmp_code_objects(version, is_pypy, code_obj1, code_obj2)
|
||||
|
||||
if __name__ == '__main__':
|
||||
t1 = Token('LOAD_CONST', None, 'code_object _expandLang', 52)
|
||||
|
Reference in New Issue
Block a user