[Python-3000] Could isinstance/issubclass overriding be dangerous?

Guido van Rossum guido at python.org
Mon Apr 30 06:05:23 CEST 2007

On 4/29/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Currently, isinstance(x, C) implies that the
> C struct layout of x is compatible with that
> defined by C. I'm worried that changing this
> could cause difficulties for extension modules
> that use PyObject_IsInstance do decide what
> to do with things, e.g. in a binary operator
> method.

Unless they were looking at classic classes, why wouldn't they be
using the specific Py<Type>_Check() macros? If you want this argument
to be taken serious, use Google code search (code.google.com) or a
similar source code search engine to find examples that would break.

Again, the only envisioned overloading is where the 2nd argument is an ABC.

Also, note that PyObject_IsInstance already returns abstract results
when the first argument is a proxy instance.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-3000 mailing list