Commit 4205ba0b authored by Guido van Rossum's avatar Guido van Rossum

Another comparison patch-up: comparing a type with a dynamic metatype

to one with a static metatype raised an obscure error.
parent 9616dc05
...@@ -921,6 +921,13 @@ def dynamics(): ...@@ -921,6 +921,13 @@ def dynamics():
verify(L(3)*2 == 6) verify(L(3)*2 == 6)
verify(L(3)*L(2) == 6) verify(L(3)*L(2) == 6)
# Test comparison of classes with dynamic metaclasses
class dynamicmetaclass(type):
__dynamic__ = 1
class someclass:
__metaclass__ = dynamicmetaclass
verify(someclass != object)
def errors(): def errors():
if verbose: print "Testing errors..." if verbose: print "Testing errors..."
......
...@@ -2033,7 +2033,8 @@ wrap_cmpfunc(PyObject *self, PyObject *args, void *wrapped) ...@@ -2033,7 +2033,8 @@ wrap_cmpfunc(PyObject *self, PyObject *args, void *wrapped)
if (!PyArg_ParseTuple(args, "O", &other)) if (!PyArg_ParseTuple(args, "O", &other))
return NULL; return NULL;
if (!PyType_IsSubtype(other->ob_type, self->ob_type)) { if (other->ob_type->tp_compare != func &&
!PyType_IsSubtype(other->ob_type, self->ob_type)) {
PyErr_Format( PyErr_Format(
PyExc_TypeError, PyExc_TypeError,
"%s.__cmp__(x,y) requires y to be a '%s', not a '%s'", "%s.__cmp__(x,y) requires y to be a '%s', not a '%s'",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment