factor out constant
This commit is contained in:
parent
061913edb6
commit
6ef9a844f2
|
@ -10,6 +10,8 @@ __all__ = ["dis", "disassemble", "distb", "disco",
|
||||||
"findlinestarts", "findlabels"] + _opcodes_all
|
"findlinestarts", "findlabels"] + _opcodes_all
|
||||||
del _opcodes_all
|
del _opcodes_all
|
||||||
|
|
||||||
|
_have_code = (types.MethodType, types.FunctionType, types.CodeType, type)
|
||||||
|
|
||||||
def dis(x=None):
|
def dis(x=None):
|
||||||
"""Disassemble classes, methods, functions, or code.
|
"""Disassemble classes, methods, functions, or code.
|
||||||
|
|
||||||
|
@ -26,8 +28,7 @@ def dis(x=None):
|
||||||
if hasattr(x, '__dict__'):
|
if hasattr(x, '__dict__'):
|
||||||
items = sorted(x.__dict__.items())
|
items = sorted(x.__dict__.items())
|
||||||
for name, x1 in items:
|
for name, x1 in items:
|
||||||
if isinstance(x1, (types.MethodType, types.FunctionType,
|
if isinstance(x1, _have_code):
|
||||||
types.CodeType, type)):
|
|
||||||
print("Disassembly of %s:" % name)
|
print("Disassembly of %s:" % name)
|
||||||
try:
|
try:
|
||||||
dis(x1)
|
dis(x1)
|
||||||
|
|
Loading…
Reference in New Issue