Skip to content

Commit ac057c6

Browse files
committed
Change error message
1 parent 8953192 commit ac057c6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Objects/unicodeobject.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11012,14 +11012,18 @@ _PyUnicode_Equal(PyObject *str1, PyObject *str2)
1101211012
int
1101311013
PyUnicode_Equal(PyObject *str1, PyObject *str2)
1101411014
{
11015-
if (PyUnicode_Check(str1) && PyUnicode_Check(str2)) {
11016-
return _PyUnicode_Equal(str1, str2);
11015+
if (!PyUnicode_Check(str1)) {
11016+
PyErr_Format(PyExc_TypeError,
11017+
"first argument must be str, not %T", str1);
11018+
return -1;
11019+
}
11020+
if (!PyUnicode_Check(str2)) {
11021+
PyErr_Format(PyExc_TypeError,
11022+
"second argument must be str, not %T", str2);
11023+
return -1;
1101711024
}
1101811025

11019-
PyErr_Format(PyExc_TypeError,
11020-
"Can't compare %T and %T",
11021-
str1, str2);
11022-
return -1;
11026+
return _PyUnicode_Equal(str1, str2);
1102311027
}
1102411028

1102511029

0 commit comments

Comments
 (0)