Support code with old style classes at runtime
Old style classes do not have a `__class__` attribute. This code thus
would so far fail with an `AttributeError`.
Specifically this code would cause exceptions from the debugger when
debugging code that referenced `xml.etree.Element` instances at
runtime, as utilized by the markdown library.
@@ -134,7 +134,10 @@ def get_clsname_for_code(code, frame):
if inspect.isclass(first_arg_obj): # class method
first_arg_class = first_arg_obj
else: # instance method
+ if hasattr(first_arg_obj, "__class__"):
first_arg_class = first_arg_obj.__class__
+ else: # old style class, fall back on type
+ first_arg_class = type(first_arg_obj)
func_name = code.co_name
if hasattr(first_arg_class, func_name):
method = getattr(first_arg_class, func_name)
