summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-04-04 23:26:50 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-04-04 23:26:50 (GMT)
commit6ef9a844f2afa6c2cb4a8f6aa98dae7bd3715362 (patch)
treeac7032bb4b8dd519bca611ee119e9cbeea611fa8
parent061913edb6f8c50e7881e77956ae8b8f4dc2bcd7 (diff)
downloadcpython-6ef9a844f2afa6c2cb4a8f6aa98dae7bd3715362.zip
cpython-6ef9a844f2afa6c2cb4a8f6aa98dae7bd3715362.tar.gz
cpython-6ef9a844f2afa6c2cb4a8f6aa98dae7bd3715362.tar.bz2
factor out constant
-rw-r--r--Lib/dis.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index 2b400dc..2c4e828 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -10,6 +10,8 @@ __all__ = ["dis", "disassemble", "distb", "disco",
"findlinestarts", "findlabels"] + _opcodes_all
del _opcodes_all
+_have_code = (types.MethodType, types.FunctionType, types.CodeType, type)
+
def dis(x=None):
"""Disassemble classes, methods, functions, or code.
@@ -26,8 +28,7 @@ def dis(x=None):
if hasattr(x, '__dict__'):
items = sorted(x.__dict__.items())
for name, x1 in items:
- if isinstance(x1, (types.MethodType, types.FunctionType,
- types.CodeType, type)):
+ if isinstance(x1, _have_code):
print("Disassembly of %s:" % name)
try:
dis(x1)