summaryrefslogtreecommitdiffstats
path: root/Lib/dis.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-01-19 02:41:41 (GMT)
committerGuido van Rossum <guido@python.org>2001-01-19 02:41:41 (GMT)
commitfc53c13dd5de26fa862c812a18b6f36bbee60ea0 (patch)
treef1ae9c90adc3a2feca124fa7c40be64c1e52121f /Lib/dis.py
parent8dabbf149e351c801a7d3b65891c49949be8251c (diff)
downloadcpython-fc53c13dd5de26fa862c812a18b6f36bbee60ea0.zip
cpython-fc53c13dd5de26fa862c812a18b6f36bbee60ea0.tar.gz
cpython-fc53c13dd5de26fa862c812a18b6f36bbee60ea0.tar.bz2
Checking in a slight variation of Barry's patch 103303.
Diffstat (limited to 'Lib/dis.py')
-rw-r--r--Lib/dis.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index 8c15919..6ecefd3 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -15,6 +15,10 @@ def dis(x=None):
return
if type(x) is types.InstanceType:
x = x.__class__
+ if hasattr(x, 'im_func'):
+ x = x.im_func
+ if hasattr(x, 'func_code'):
+ x = x.func_code
if hasattr(x, '__dict__'):
items = x.__dict__.items()
items.sort()
@@ -28,17 +32,12 @@ def dis(x=None):
except TypeError, msg:
print "Sorry:", msg
print
+ elif hasattr(x, 'co_code'):
+ disassemble(x)
else:
- if hasattr(x, 'im_func'):
- x = x.im_func
- if hasattr(x, 'func_code'):
- x = x.func_code
- if hasattr(x, 'co_code'):
- disassemble(x)
- else:
- raise TypeError, \
- "don't know how to disassemble %s objects" % \
- type(x).__name__
+ raise TypeError, \
+ "don't know how to disassemble %s objects" % \
+ type(x).__name__
def distb(tb=None):
"""Disassemble a traceback (default: last traceback)."""