Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
gh-112087: Make list.sort to be threaf-safe for PEP 703.
  • Loading branch information
corona10 committed Mar 9, 2024
commit 5a55c7d123c33425119bf55c72959392f1bfbae8
4 changes: 3 additions & 1 deletion Objects/clinic/listobject.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2577,6 +2577,7 @@ unsafe_tuple_compare(PyObject *v, PyObject *w, MergeState *ms)
* duplicated).
*/
/*[clinic input]
@critical_section
list.sort

*
Expand All @@ -2596,7 +2597,7 @@ The reverse flag can be set to sort in descending order.

static PyObject *
list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
/*[clinic end generated code: output=57b9f9c5e23fbe42 input=a74c4cd3ec6b5c08]*/
/*[clinic end generated code: output=57b9f9c5e23fbe42 input=667bf25d0e3a3676]*/
{
MergeState ms;
Py_ssize_t nremaining;
Expand Down Expand Up @@ -2870,7 +2871,9 @@ PyList_Sort(PyObject *v)
PyErr_BadInternalCall();
return -1;
}
Py_BEGIN_CRITICAL_SECTION(v);
v = list_sort_impl((PyListObject *)v, NULL, 0);
Py_END_CRITICAL_SECTION();
if (v == NULL)
return -1;
Py_DECREF(v);
Expand Down