mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Fix comparing complex to non-complex numbers.
This commit is contained in:
parent
4886cc331f
commit
18a67ba0bd
2 changed files with 4 additions and 38 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue