[New-bugs-announce] [issue7491] metaclass __cmp__ is ignored

Jean-Paul Calderone report at bugs.python.org
Sun Dec 13 16:58:47 CET 2009

New submission from Jean-Paul Calderone <exarkun at divmod.com>:

Here's an example of a metaclass with a __cmp__ special:

    exarkun at boson:/tmp$ cat metacmp.py
    class X(type):
        def __cmp__(self, other):
            return -1

    class Y:
        __metaclass__ = X

    print Y < Y
    exarkun at boson:/tmp$ python2.5 metacmp.py
    exarkun at boson:/tmp$ python2.6 metacmp.py
    exarkun at boson:/tmp$

In Python 2.6 and Python 2.7a1, the __cmp__ isn't even invoked, as it
was in Python 2.5.

This breaks the ordering of item types in Axiom.  A brief search reveals
that sympy also ran into the problem, but they may have since worked
around it.

components: Interpreter Core
messages: 96334
nosy: exarkun
severity: normal
status: open
title: metaclass __cmp__ is ignored
versions: Python 2.6, Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list