mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Marc-Andre Lemburg:
* TypeErrors during comparing of mixed type arguments including a Unicode object are now masked (just like they are for all other combinations).
This commit is contained in:
parent
52c2359a59
commit
b244f6950b
1 changed files with 15 additions and 2 deletions
|
@ -347,8 +347,21 @@ PyObject_Compare(v, w)
|
||||||
return cmp;
|
return cmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (PyUnicode_Check(v) || PyUnicode_Check(w))
|
else if (PyUnicode_Check(v) || PyUnicode_Check(w)) {
|
||||||
return PyUnicode_Compare(v, w);
|
int result = PyUnicode_Compare(v, w);
|
||||||
|
if (result == -1 && PyErr_Occurred() &&
|
||||||
|
PyErr_ExceptionMatches(PyExc_TypeError))
|
||||||
|
/* TypeErrors are ignored: if Unicode coercion
|
||||||
|
fails due to one of the arguments not
|
||||||
|
having the right type, we continue as
|
||||||
|
defined by the coercion protocol (see
|
||||||
|
above). Luckily, decoding errors are
|
||||||
|
reported as ValueErrors and are not masked
|
||||||
|
by this technique. */
|
||||||
|
PyErr_Clear();
|
||||||
|
else
|
||||||
|
return result;
|
||||||
|
}
|
||||||
else if (vtp->tp_as_number != NULL)
|
else if (vtp->tp_as_number != NULL)
|
||||||
vname = "";
|
vname = "";
|
||||||
else if (wtp->tp_as_number != NULL)
|
else if (wtp->tp_as_number != NULL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue