File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -351,7 +351,11 @@ list_item_impl(PyListObject *self, Py_ssize_t idx)
351351 if (!valid_index (idx , size )) {
352352 goto exit ;
353353 }
354+ #ifdef Py_GIL_DISABLED
355+ item = _Py_NewRefWithLock (self -> ob_item [idx ]);
356+ #else
354357 item = Py_NewRef (self -> ob_item [idx ]);
358+ #endif
355359exit :
356360 Py_END_CRITICAL_SECTION ();
357361 return item ;
@@ -656,14 +660,15 @@ list_item(PyObject *aa, Py_ssize_t i)
656660 return NULL ;
657661 }
658662 PyObject * item ;
659- Py_BEGIN_CRITICAL_SECTION (a );
660663#ifdef Py_GIL_DISABLED
661- if (!_Py_IsOwnedByCurrentThread ((PyObject * )a ) && !_PyObject_GC_IS_SHARED (a )) {
662- _PyObject_GC_SET_SHARED (a );
664+ item = list_get_item_ref (a , i );
665+ if (item == NULL ) {
666+ PyErr_SetObject (PyExc_IndexError , & _Py_STR (list_err ));
667+ return NULL ;
663668 }
664- #endif
669+ #else
665670 item = Py_NewRef (a -> ob_item [i ]);
666- Py_END_CRITICAL_SECTION ();
671+ #endif
667672 return item ;
668673}
669674
You can’t perform that action at this time.
0 commit comments