[Zope-Coders] RE: [Zope-Checkins] CVS: Zope/doc - INSTALL.txt:1.32
Guido van Rossum
guido@python.org
Thu, 30 May 2002 13:22:26 -0400
> > Are you saying ExtensionClass instances don't support isinstance?
>
> Hmm, I just checked, and Python 2.2(.1) apparently has a fix that makes
> ExtensionClass and isinstance() play together nicely. Previously,
> isinstance() didn't think ExtensionClass instances were classes, so it
> raised a TypeError.
Maybe 2.1 had that.
> > Won't you have access to builtins like 'int' or 'str' that let you
> > create subclasses?
>
> Ah-ha, good point. We could take two approaches to this: investigate
> whether that's a problem, or ban class creation in scripts. You can
> create classes in scripts today but it's so restricted that it's not
> really worth having the capability.
Banning it seems the simplest way then. :-)
> >>- You can append "object" to the list of base classes of an
> >>ExtensionClass subclass. What does that do, I wonder?
> >
> >
> > When you do this to a classic class, the result is a new-style class.
> > I expect that when you mix an ExtensionClass and object as base
> > classes, you'll get a metaclass conflict error.
>
> Check this out. It depends on the order!
>
> [shane@shane python]$ python
> Python 2.2.1 (#1, May 10 2002, 11:57:27)
> [GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.63.1mdk)] on linux-i386
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from ExtensionClass import Base
> >>> class b(Base, object): pass
> ...
> >>> class b(object, Base): pass
> ...
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: metatype conflict among bases
ExtensionClass doesn't know about metaclasses or new-style classes, so
it doesn't check for metaclass compatibility.
I'm not sure if this is a real problem -- could this be abused to
provoke a core dump?
--Guido van Rossum (home page: http://www.python.org/~guido/)