Patch #1049 by Thomas Lee.

Changes comparisons between PyBytes and PyUnicode to return unequal
instead of raising TypeError.
This commit is contained in:
Guido van Rossum 2007-10-09 17:21:10 +00:00
parent 6ccd3f2dbc
commit 1e35e76532
2 changed files with 9 additions and 7 deletions

View file

@ -964,8 +964,8 @@ bytes_richcompare(PyObject *self, PyObject *other, int op)
error, even if the comparison is for equality. */
if (PyObject_IsInstance(self, (PyObject*)&PyUnicode_Type) ||
PyObject_IsInstance(other, (PyObject*)&PyUnicode_Type)) {
PyErr_SetString(PyExc_TypeError, "can't compare bytes and str");
return NULL;
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
self_size = _getbuffer(self, &self_bytes);