Make class detection more accurate

It's more correct to use inspect.isclass(X) instead of type(X) == type
as if some parent of the class we're trying to trace has metaclass used,
the type will be that metaclass.

Change-Id: I5102eb46a7a377eca31375a0d64951ba1fdd035d
This commit is contained in:
Dina Belova 2016-02-09 13:42:22 -08:00
parent 2d57f411a3
commit ac45be4bf0

View File

@ -148,7 +148,7 @@ def trace_cls(name, info=None, hide_args=False, trace_private=False):
"""
def decorator(cls):
clss = cls if type(cls) is type else cls.__class__
clss = cls if inspect.isclass(cls) else cls.__class__
mro_dicts = [c.__dict__ for c in inspect.getmro(clss)]
for attr_name, attr in inspect.getmembers(cls):
if not (inspect.ismethod(attr) or inspect.isfunction(attr)):