]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix dis on new style classes #8310
authorBenjamin Peterson <benjamin@python.org>
Sun, 4 Apr 2010 23:23:22 +0000 (23:23 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 4 Apr 2010 23:23:22 +0000 (23:23 +0000)
Lib/dis.py
Misc/NEWS

index edc210fbcf11b12f0588fafab00ac395c2057638..5aa09c95b6d8df8354e38be0d5163e9796302cb3 100644 (file)
@@ -10,6 +10,9 @@ __all__ = ["dis", "disassemble", "distb", "disco",
            "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 @@ def dis(x=None):
         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)
index 4cb76adc01b16e105b0987880e56e632cfb91654..0ee0c07e4afb3e230b86b655cb78c0751c8e9d13 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -49,6 +49,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #8310: Allow dis to examine new style classes.
+
 - Issue #8257: The Decimal construct now accepts a float instance
   directly, converting that float to a Decimal of equal value: