mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #5211: Complete removal of implicit coercions for the complex
type. Coercion for arithmetic operations was already removed in r78280, but that commit didn't remove coercion for rich comparisons.
This commit is contained in:
parent
ddac33882b
commit
813363743d
3 changed files with 19 additions and 19 deletions
|
|
@ -787,25 +787,8 @@ complex_richcompare(PyObject *v, PyObject *w, int op)
|
|||
Py_complex i, j;
|
||||
PyObject *res;
|
||||
|
||||
c = PyNumber_CoerceEx(&v, &w);
|
||||
if (c < 0)
|
||||
return NULL;
|
||||
if (c > 0) {
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
/* Make sure both arguments are complex. */
|
||||
if (!(PyComplex_Check(v) && PyComplex_Check(w))) {
|
||||
Py_DECREF(v);
|
||||
Py_DECREF(w);
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
|
||||
i = ((PyComplexObject *)v)->cval;
|
||||
j = ((PyComplexObject *)w)->cval;
|
||||
Py_DECREF(v);
|
||||
Py_DECREF(w);
|
||||
TO_COMPLEX(v, i);
|
||||
TO_COMPLEX(w, j);
|
||||
|
||||
if (op != Py_EQ && op != Py_NE) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue