Pretty print any supported python object (previously it only pretty printed objects...
authorMark Florisson <markflorisson88@gmail.com>
Sat, 6 Nov 2010 21:57:50 +0000 (22:57 +0100)
committerMark Florisson <markflorisson88@gmail.com>
Sat, 6 Nov 2010 21:57:50 +0000 (22:57 +0100)
Cython/Debugger/libpython.py

index ae73353f7c3b0839067c68771109a40c5a97e788..7cc7240cbb557b926cb801161482be37ae44b6dc 100644 (file)
@@ -1108,12 +1108,16 @@ class PyObjectPtrPrinter:
             proxyval = pyop.proxyval(set())
             return stringify(proxyval)
 
+
 def pretty_printer_lookup(gdbval):
     type = gdbval.type.unqualified()
     if type.code == gdb.TYPE_CODE_PTR:
         type = type.target().unqualified()
-        t = str(type)
-        if t in ("PyObject", "PyFrameObject"):
+        # do this every time to allow new subclasses to "register"
+        # alternatively, we could use a metaclass to register all the typenames
+        classes = [PyObjectPtr]
+        classes.extend(PyObjectPtr.__subclasses__())
+        if str(type) in [cls._typename for cls in classes]:
             return PyObjectPtrPrinter(gdbval)
 
 """