Skip to content

Commit 4fb3ec6

Browse files
committed
Fix PyUnicode_Compare() usage
1 parent b8ba9d9 commit 4fb3ec6

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

‎pythoncapi_compat.h‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,14 +1613,11 @@ static inline int PyUnicode_Equal(PyObject *str1, PyObject *str2)
16131613
return _PyUnicode_EQ(str1, str2);
16141614
#else
16151615
{
1616-
int res = PyUnicode_Compare(str1, str2);
1617-
if (res == 0) {
1618-
return 1;
1619-
}
1620-
if (res > 0) {
1621-
return 0;
1616+
int cmp = PyUnicode_Compare(str1, str2);
1617+
if (cmp == -1 && PyErr_Occurred()) {
1618+
return -1;
16221619
}
1623-
return -1;
1620+
return (cmp == 0);
16241621
}
16251622
#endif
16261623
}

0 commit comments

Comments
 (0)