1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#! /bin/sh -e
# DP: Fix issue #8310: Allow dis to examine new style classes.
dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
pdir="-d $3"
dir="$3/"
elif [ $# -ne 1 ]; then
echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
exit 1
fi
case "$1" in
-patch)
patch $pdir -f --no-backup-if-mismatch -p0 < $0
;;
-unpatch)
patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
;;
*)
echo >&2 "usage: `basename $0`: -patch|-unpatch [-d <srcdir>]"
exit 1
esac
exit 0
Index: Lib/dis.py
===================================================================
--- Lib/dis.py (Revision 79768)
+++ Lib/dis.py (Revision 79769)
@@ -10,6 +10,9 @@
"findlinestarts", "findlabels"] + _opcodes_all
del _opcodes_all
+_have_code = (types.MethodType, types.FunctionType, types.CodeType,
+ types.ClassType, type)
+
def dis(x=None):
"""Disassemble classes, methods, functions, or code.
@@ -29,10 +32,7 @@
items = x.__dict__.items()
items.sort()
for name, x1 in items:
- if isinstance(x1, (types.MethodType,
- types.FunctionType,
- types.CodeType,
- types.ClassType)):
+ if isinstance(x1, _have_code):
print "Disassembly of %s:" % name
try:
dis(x1)
|