You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
inspect.iscode -> hasattr for now until we write a cross-version iscode
This commit is contained in:
@@ -92,7 +92,7 @@ def get_python_parser(version, debug_parser):
|
|||||||
def python_parser(version, co, out=sys.stdout, showasm=False,
|
def python_parser(version, co, out=sys.stdout, showasm=False,
|
||||||
parser_debug=PARSER_DEFAULT_DEBUG):
|
parser_debug=PARSER_DEFAULT_DEBUG):
|
||||||
import inspect
|
import inspect
|
||||||
assert inspect.iscode(co)
|
assert hasattr(co, 'co_name')
|
||||||
from uncompyle6.scanner import get_scanner
|
from uncompyle6.scanner import get_scanner
|
||||||
scanner = get_scanner(version)
|
scanner = get_scanner(version)
|
||||||
tokens, customize = scanner.disassemble(co)
|
tokens, customize = scanner.disassemble(co)
|
||||||
|
@@ -98,7 +98,7 @@ class Scanner34(scan3.Scanner3):
|
|||||||
# other than LOAD_CONST, but we'll start out with just this for now.
|
# other than LOAD_CONST, but we'll start out with just this for now.
|
||||||
if opname in ['LOAD_CONST']:
|
if opname in ['LOAD_CONST']:
|
||||||
const = inst.argval
|
const = inst.argval
|
||||||
if inspect.iscode(const):
|
if hasattr(const, 'co_name')):
|
||||||
if const.co_name == '<lambda>':
|
if const.co_name == '<lambda>':
|
||||||
opname = 'LOAD_LAMBDA'
|
opname = 'LOAD_LAMBDA'
|
||||||
elif const.co_name == '<genexpr>':
|
elif const.co_name == '<genexpr>':
|
||||||
|
@@ -138,8 +138,8 @@ def cmp_code_objects(version, code_obj1, code_obj2, name=''):
|
|||||||
This is the main part of this module.
|
This is the main part of this module.
|
||||||
"""
|
"""
|
||||||
# print code_obj1, type(code_obj2)
|
# print code_obj1, type(code_obj2)
|
||||||
assert inspect.iscode(code_obj1)
|
assert code_obj1, hasattr('co_name')
|
||||||
assert inspect.iscode(code_obj2)
|
assert code_obj2, hasattr('co_name')
|
||||||
# print dir(code_obj1)
|
# print dir(code_obj1)
|
||||||
if isinstance(code_obj1, object):
|
if isinstance(code_obj1, object):
|
||||||
# new style classes (Python 2.2)
|
# new style classes (Python 2.2)
|
||||||
@@ -307,8 +307,8 @@ def cmp_code_objects(version, code_obj1, code_obj2, name=''):
|
|||||||
elif member == 'co_consts':
|
elif member == 'co_consts':
|
||||||
# partial optimization can make the co_consts look different,
|
# partial optimization can make the co_consts look different,
|
||||||
# so we'll just compare the code consts
|
# so we'll just compare the code consts
|
||||||
codes1 = ( c for c in code_obj1.co_consts if inspect.iscode(c) )
|
codes1 = ( c for c in code_obj1.co_consts if hasattr(c, 'co_consts') )
|
||||||
codes2 = ( c for c in code_obj2.co_consts if inspect.iscode(c) )
|
codes2 = ( c for c in code_obj2.co_consts if hasattr(c, 'co_consts') )
|
||||||
|
|
||||||
for c1, c2 in zip(codes1, codes2):
|
for c1, c2 in zip(codes1, codes2):
|
||||||
cmp_code_objects(version, c1, c2, name=name)
|
cmp_code_objects(version, c1, c2, name=name)
|
||||||
|
Reference in New Issue
Block a user