@@ -30,7 +30,6 @@ get_list_state(void)
30
30
}
31
31
#endif
32
32
33
-
34
33
/* Ensure ob_item has room for at least newsize elements, and set
35
34
* ob_size to newsize. If newsize > ob_size on entry, the content
36
35
* of the new slots at exit is undefined heap trash; it's the caller's
@@ -221,8 +220,9 @@ PyList_Size(PyObject *op)
221
220
PyErr_BadInternalCall ();
222
221
return -1 ;
223
222
}
224
- else
225
- return Py_SIZE (op );
223
+ else {
224
+ return PyList_GET_SIZE (op );
225
+ }
226
226
}
227
227
228
228
static inline int
@@ -328,7 +328,7 @@ PyList_Insert(PyObject *op, Py_ssize_t where, PyObject *newitem)
328
328
int
329
329
_PyList_AppendTakeRefListResize (PyListObject * self , PyObject * newitem )
330
330
{
331
- Py_ssize_t len = PyList_GET_SIZE (self );
331
+ Py_ssize_t len = Py_SIZE (self );
332
332
assert (self -> allocated == -1 || self -> allocated == len );
333
333
if (list_resize (self , len + 1 ) < 0 ) {
334
334
Py_DECREF (newitem );
342
342
PyList_Append (PyObject * op , PyObject * newitem )
343
343
{
344
344
if (PyList_Check (op ) && (newitem != NULL )) {
345
- return _PyList_AppendTakeRef ((PyListObject * )op , Py_NewRef (newitem ));
345
+ int ret ;
346
+ Py_BEGIN_CRITICAL_SECTION (op );
347
+ ret = _PyList_AppendTakeRef ((PyListObject * )op , Py_NewRef (newitem ));
348
+ Py_END_CRITICAL_SECTION ();
349
+ return ret ;
346
350
}
347
351
PyErr_BadInternalCall ();
348
352
return -1 ;
@@ -473,7 +477,7 @@ static PyObject *
473
477
list_item (PyObject * aa , Py_ssize_t i )
474
478
{
475
479
PyListObject * a = (PyListObject * )aa ;
476
- if (!valid_index (i , Py_SIZE (a ))) {
480
+ if (!valid_index (i , PyList_GET_SIZE (a ))) {
477
481
PyErr_SetObject (PyExc_IndexError , & _Py_STR (list_err ));
478
482
return NULL ;
479
483
}
@@ -511,6 +515,8 @@ PyList_GetSlice(PyObject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
511
515
PyErr_BadInternalCall ();
512
516
return NULL ;
513
517
}
518
+ PyObject * ret ;
519
+ Py_BEGIN_CRITICAL_SECTION (a );
514
520
if (ilow < 0 ) {
515
521
ilow = 0 ;
516
522
}
@@ -523,7 +529,9 @@ PyList_GetSlice(PyObject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
523
529
else if (ihigh > Py_SIZE (a )) {
524
530
ihigh = Py_SIZE (a );
525
531
}
526
- return list_slice ((PyListObject * )a , ilow , ihigh );
532
+ ret = list_slice ((PyListObject * )a , ilow , ihigh );
533
+ Py_END_CRITICAL_SECTION ();
534
+ return ret ;
527
535
}
528
536
529
537
static PyObject *
0 commit comments