Skip to content
Prev Previous commit
Next Next commit
Address code review
  • Loading branch information
corona10 committed Feb 28, 2024
commit e7f36834739163092fc46ca79fc2bc963b27d93e
13 changes: 6 additions & 7 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,19 +497,18 @@ static PyObject *
list_item(PyObject *aa, Py_ssize_t i)
{
PyListObject *a = (PyListObject *)aa;
PyObject *item = NULL;
if (!valid_index(i, PyList_GET_SIZE(a))) {
PyErr_SetObject(PyExc_IndexError, &_Py_STR(list_err));
return NULL;
}
PyObject *item;
Py_BEGIN_CRITICAL_SECTION(a);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will want the fast path to do this without locking soon.

#ifdef Py_GIL_DISABLED
if (!_PyObject_GC_IS_SHARED(a)) {
if (!_Py_IsOwnedByCurrentThread((PyObject *)a) && !_PyObject_GC_IS_SHARED(a)) {
_PyObject_GC_SET_SHARED(a);
}
#endif
if (!valid_index(i, PyList_GET_SIZE(a))) {
PyErr_SetObject(PyExc_IndexError, &_Py_STR(list_err));
goto exit;
}
item = Py_NewRef(a->ob_item[i]);
exit:
Py_END_CRITICAL_SECTION();
return item;
}
Expand Down