[Python-Dev] Small misleadingness in docs (original) (raw)
Georg Brandl g.brandl at gmx.net
Sat Feb 14 10:42:39 CET 2009
- Previous message: [Python-Dev] Small misleadingness in docs
- Next message: [Python-Dev] Small misleadingness in docs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Raymond Hettinger schrieb:
[Greg Ewing]
I've discovered something slightly misleading in the docs for PyObjectIsInstance:
When testing if B is a subclass of A, if A is B, PyObjectIsSubclass returns true. If A and B are different objects, B's bases attribute is searched... This suggests that issubclass(A, A) will always be true, regardless of what attributes A has. However, this turns out not to be so -- A must also have a bases attribute, otherwise it's rejected as not being sufficiently class-like. This smells like a bug that brings issubclass() out of sync with isinstance(). Perhaps issubclass() should do what the docs say and start by testing whether A and B are the same object.
Since I cannot imagine a scenario where you would want to have non-classes as the arguments of issubclass(), making sure that both are classes sounds like a good idea to prevent bugs.
Georg
-- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.
- Previous message: [Python-Dev] Small misleadingness in docs
- Next message: [Python-Dev] Small misleadingness in docs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]