Issues

Issue #114 resolved

debugging with pudb crashes

roman schulz
created an issue

I got an exception while debugging (printed object is PyTypeObject without name attribute)

Traceback (most recent call last):
  File "/usr/lib/python2.6/runpy.py", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.6/runpy.py", line 34, in _run_code
    exec code in run_globals
  File "/usr/lib/pymodules/python2.6/pudb/run.py", line 36, in <module>
    main()
  File "/usr/lib/pymodules/python2.6/pudb/run.py", line 30, in main
    steal_output=options.steal_output)
  File "/usr/lib/pymodules/python2.6/pudb/__init__.py", line 56, in runscript
    dbg.interaction(None, sys.exc_info())
  File "/usr/lib/pymodules/python2.6/pudb/debugger.py", line 170, in interaction
    self.set_frame_index(index)
  File "/usr/lib/pymodules/python2.6/pudb/debugger.py", line 131, in set_frame_index
    self.ui.update_var_view()
  File "/usr/lib/pymodules/python2.6/pudb/debugger.py", line 1202, in update_var_view
    locals, globals)
  File "/usr/lib/pymodules/python2.6/pudb/var_view.py", line 359, in make_var_view
    tmv_walker.walk_value("", var, locals[var])
  File "/usr/lib/pymodules/python2.6/pudb/var_view.py", line 149, in walk_value
    displayed_value = type(value).__name__
AttributeError: __name__

I think it could be solved in current master as follows (file pudb/var_view.py:230):

def type_stringifier(value):
    if HAVE_NUMPY and isinstance(value, numpy.ndarray):
        return "ndarray %s %s" % (value.dtype, value.shape)
    elif isinstance(value, STR_SAFE_TYPES):
        try:
            return str(value)
        except Exception:
            pass

-    return type(value).__name__
+    if hasattr(value, "__name__"):
+        return type(value).__name__
+    return "unknown"

Comments (2)

  1. Log in to comment