Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix debug assertion failure in ``unsafe_latin_compare``,
``unsafe_long_compare``, and ``unsafe_float_compare`` when
:c:func:`PyObject_RichCompareBool` returns ``-1`` on error.
15 changes: 12 additions & 3 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2830,7 +2830,10 @@ unsafe_latin_compare(PyObject *v, PyObject *w, MergeState *ms)
res < 0 :
PyUnicode_GET_LENGTH(v) < PyUnicode_GET_LENGTH(w));

assert(res == PyObject_RichCompareBool(v, w, Py_LT));;
#ifndef NDEBUG
int cmp = PyObject_RichCompareBool(v, w, Py_LT);
assert(cmp < 0 || res == cmp);
#endif
Comment on lines +2833 to +2836
return res;
}

Expand All @@ -2855,7 +2858,10 @@ unsafe_long_compare(PyObject *v, PyObject *w, MergeState *ms)
w0 = _PyLong_CompactValue(wl);

res = v0 < w0;
assert(res == PyObject_RichCompareBool(v, w, Py_LT));
#ifndef NDEBUG
int cmp = PyObject_RichCompareBool(v, w, Py_LT);
assert(cmp < 0 || res == cmp);
#endif
Comment on lines +2861 to +2864
return res;
}

Expand All @@ -2870,7 +2876,10 @@ unsafe_float_compare(PyObject *v, PyObject *w, MergeState *ms)
assert(Py_IS_TYPE(w, &PyFloat_Type));

res = PyFloat_AS_DOUBLE(v) < PyFloat_AS_DOUBLE(w);
assert(res == PyObject_RichCompareBool(v, w, Py_LT));
#ifndef NDEBUG
int cmp = PyObject_RichCompareBool(v, w, Py_LT);
assert(cmp < 0 || res == cmp);
#endif
Comment on lines +2879 to +2882
return res;
}

Expand Down
Loading