[Python-Dev] new metaclass error condition checks

Thomas Wouters thomas at python.org
Fri Apr 20 15:56:02 CEST 2007


On 4/17/07, Jean-Paul Calderone <exarkun at divmod.com> wrote:
>
> I just noticed r53997 (from some unit tests it broke), which disallowed
> things
> like this:
>
>     class X(object):
>         def __repr__(self):
>             return "blah"
>
>     class Y(X, type):
>         pass
>
>     class Z:
>         __metaclass__ = Y
>
> Making X classic eliminates the TypeError, and is probably an acceptable
> fix
> in a lot of cases (at least as long as classic classes are available).  I
> wonder if the ability to override type special methods like this was
> considered
> when the change was made, though?


Probably not, or at least not consciously. I think the point is that 'type'
and its subclasses are special enough that this warrants a separate 'X' that
inherits from 'type' rather than 'object'. Reduced reusability, but how
badly does this affect you in the real world, really?

-- 
Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20070420/ed0c6bef/attachment.html 


More information about the Python-Dev mailing list