diff -r bff88c866886 Lib/inspect.py --- a/Lib/inspect.py Thu Apr 09 10:27:25 2015 +0200 +++ b/Lib/inspect.py Thu Apr 09 11:42:19 2015 -0400 @@ -381,7 +381,7 @@ # first look in the classes for srch_cls in class_bases: srch_obj = getattr(srch_cls, name, None) - if srch_obj == get_obj: + if srch_obj is get_obj: last_cls = srch_cls # then check the metaclasses for srch_cls in metamro: @@ -389,7 +389,7 @@ srch_obj = srch_cls.__getattr__(cls, name) except AttributeError: continue - if srch_obj == get_obj: + if srch_obj is get_obj: last_cls = srch_cls if last_cls is not None: homecls = last_cls @@ -403,7 +403,7 @@ # unable to locate the attribute anywhere, most likely due to # buggy custom __dir__; discard and move on continue - obj = get_obj or dict_obj + obj = get_obj if get_obj is not None else dict_obj # Classify the object or its descriptor. if isinstance(dict_obj, staticmethod): kind = "static method" diff -r bff88c866886 Lib/test/test_inspect.py --- a/Lib/test/test_inspect.py Thu Apr 09 10:27:25 2015 +0200 +++ b/Lib/test/test_inspect.py Thu Apr 09 11:42:19 2015 -0400 @@ -817,6 +817,21 @@ should_find_ga = inspect.Attribute('ham', 'data', Meta, 'spam') self.assertIn(should_find_ga, inspect.classify_class_attrs(VA)) + def test_classify_overrides_bool(self): + class NoBool(object): + def __eq__(self, other): + return NoBool() + + def __bool__(self): + raise NotImplementedError( + "This object does not specify a boolean value") + + class HasNB(object): + dd = NoBool() + + should_find_attr = inspect.Attribute('dd', 'data', HasNB, HasNB.dd) + self.assertIn(should_find_attr, inspect.classify_class_attrs(HasNB)) + def test_classify_metaclass_class_attribute(self): class Meta(type): fish = 'slap'