Issue 1225107: inspect.isclass() fails with custom getattr (original) (raw)

inspect.isclass() can return True for instances of classes
which define a getattr method. For example:

class Namespace(unicode):
... def getattr(self, attr):
... return '<%s>' % (self + attr)
...
inspect.isclass(Namespace('foo'))
True

Changing inspect.isclass() to:
return isinstance(object, (types.ClassType, type))
solves this issue.

The check for bases is no longer need due to
type/class unification.