The following sequence causes isinstance to raise an exception rather than to return False. >>> class foo: ... pass ... >>> import collections >>> isinstance(foo,collections.Callable) True >>> isinstance(foo(),collections.Callable) Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/abc.py", line 131, in __instancecheck__ return (cls.__subclasscheck__(subclass) or File "/usr/lib/python2.6/abc.py", line 147, in __subclasscheck__ ok = cls.__subclasshook__(subclass) File "/usr/lib/python2.6/_abcoll.py", line 117, in __subclasshook__ if any("__call__" in B.__dict__ for B in C.__mro__): AttributeError: class foo has no attribute '__mro__' >>>
Confirmed with all others "isinstance(..., collections.Hashable)" and similar. According to the documentation, we might expect the same behavior as for new-style class.
Fixed in r78800. Additional tests backported to 3.x.
History
Date
User
Action
Args
2022-04-11 14:56:56
admin
set
github: 51873
2010-03-08 15:35:44
flox
set
status: open -> closedtitle: isinstance(... ,collections.Callable) fails with oldstyle class i nstances -> isinstance(... ,collections.Callable) fails with oldstyle class instancesmessages: + resolution: accepted -> fixedstage: commit review -> resolved