mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Checking in a slight variation of Barry's patch 103303.
This commit is contained in:
parent
8dabbf149e
commit
fc53c13dd5
1 changed files with 9 additions and 10 deletions
11
Lib/dis.py
11
Lib/dis.py
|
@ -15,6 +15,10 @@ def dis(x=None):
|
||||||
return
|
return
|
||||||
if type(x) is types.InstanceType:
|
if type(x) is types.InstanceType:
|
||||||
x = x.__class__
|
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__'):
|
if hasattr(x, '__dict__'):
|
||||||
items = x.__dict__.items()
|
items = x.__dict__.items()
|
||||||
items.sort()
|
items.sort()
|
||||||
|
@ -28,12 +32,7 @@ def dis(x=None):
|
||||||
except TypeError, msg:
|
except TypeError, msg:
|
||||||
print "Sorry:", msg
|
print "Sorry:", msg
|
||||||
print
|
print
|
||||||
else:
|
elif hasattr(x, 'co_code'):
|
||||||
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)
|
disassemble(x)
|
||||||
else:
|
else:
|
||||||
raise TypeError, \
|
raise TypeError, \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue