Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e7f3683

Browse filesBrowse files
committed
Address code review
1 parent df90d37 commit e7f3683
Copy full SHA for e7f3683

File tree

Expand file treeCollapse file tree

1 file changed

+6
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-7
lines changed

‎Objects/listobject.c

Copy file name to clipboardExpand all lines: Objects/listobject.c
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -497,19 +497,18 @@ static PyObject *
497497
list_item(PyObject *aa, Py_ssize_t i)
498498
{
499499
PyListObject *a = (PyListObject *)aa;
500-
PyObject *item = NULL;
500+
if (!valid_index(i, PyList_GET_SIZE(a))) {
501+
PyErr_SetObject(PyExc_IndexError, &_Py_STR(list_err));
502+
return NULL;
503+
}
504+
PyObject *item;
501505
Py_BEGIN_CRITICAL_SECTION(a);
502506
#ifdef Py_GIL_DISABLED
503-
if (!_PyObject_GC_IS_SHARED(a)) {
507+
if (!_Py_IsOwnedByCurrentThread((PyObject *)a) && !_PyObject_GC_IS_SHARED(a)) {
504508
_PyObject_GC_SET_SHARED(a);
505509
}
506510
#endif
507-
if (!valid_index(i, PyList_GET_SIZE(a))) {
508-
PyErr_SetObject(PyExc_IndexError, &_Py_STR(list_err));
509-
goto exit;
510-
}
511511
item = Py_NewRef(a->ob_item[i]);
512-
exit:
513512
Py_END_CRITICAL_SECTION();
514513
return item;
515514
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.