summaryrefslogtreecommitdiffstats
path: root/Objects/complexobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2006-08-21 18:27:07 (GMT)
committerGuido van Rossum <guido@python.org>2006-08-21 18:27:07 (GMT)
commit18a67ba0bd6d23da454e975f814dad50d7e09cdb (patch)
tree7e4e5bbf150af0df14030e184c9a6f4a5548b0f7 /Objects/complexobject.c
parent4886cc331ff158f8ede74878a436adfad205bd2d (diff)
downloadcpython-18a67ba0bd6d23da454e975f814dad50d7e09cdb.zip
cpython-18a67ba0bd6d23da454e975f814dad50d7e09cdb.tar.gz
cpython-18a67ba0bd6d23da454e975f814dad50d7e09cdb.tar.bz2
Fix comparing complex to non-complex numbers.
Diffstat (limited to 'Objects/complexobject.c')
-rw-r--r--Objects/complexobject.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index e081256..2713e3e 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -576,19 +576,13 @@ complex_nonzero(PyComplexObject *v)
static PyObject *
complex_richcompare(PyObject *v, PyObject *w, int op)
{
- Py_complex i, j;
PyObject *res;
-
- /* Make sure both arguments are complex. */
- if (!(PyComplex_Check(v) && PyComplex_Check(w))) {
- Py_INCREF(Py_NotImplemented);
- return Py_NotImplemented;
- }
-
- i = ((PyComplexObject *)v)->cval;
- j = ((PyComplexObject *)w)->cval;
+ Py_complex i, j;
+ TO_COMPLEX(v, i);
+ TO_COMPLEX(w, j);
if (op != Py_EQ && op != Py_NE) {
+ /* XXX Should eventually return NotImplemented */
PyErr_SetString(PyExc_TypeError,
"no ordering relation is defined for complex numbers");
return NULL;