File tree 1 file changed +10
-5
lines changed
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)
351
351
if (!valid_index (idx , size )) {
352
352
goto exit ;
353
353
}
354
+ #ifdef Py_GIL_DISABLED
355
+ item = _Py_NewRefWithLock (self -> ob_item [idx ]);
356
+ #else
354
357
item = Py_NewRef (self -> ob_item [idx ]);
358
+ #endif
355
359
exit :
356
360
Py_END_CRITICAL_SECTION ();
357
361
return item ;
@@ -656,14 +660,15 @@ list_item(PyObject *aa, Py_ssize_t i)
656
660
return NULL ;
657
661
}
658
662
PyObject * item ;
659
- Py_BEGIN_CRITICAL_SECTION (a );
660
663
#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 ;
663
668
}
664
- #endif
669
+ #else
665
670
item = Py_NewRef (a -> ob_item [i ]);
666
- Py_END_CRITICAL_SECTION ();
671
+ #endif
667
672
return item ;
668
673
}
669
674
You can’t perform that action at this time.
0 commit comments