isinstance is broken

Carl Banks imbosol at vt.edu
Mon Jan 20 14:24:59 EST 2003


Michael Hudson wrote:
> Carl Banks <imbosol at vt.edu> writes:
> 
>> I think a C extension could create an object that is not an instance
>> of object, in which case isinstance(something,object) would return
>> false.
> 
> I think not, because a type is always an object.
> 
> isinstance(c, object) == issubclass(type(c), object) == True.
>                      ^
>           except for old-style instances 
> 
> My reading of the source would seem to confirm this, but I could well
> have missed something...

Correct.  If you leave tp_bases empty, Python happily sets it to a
tuple of PyBaseObject.


-- 
CARL BANKS




More information about the Python-list mailing list