#include "pycore_global_objects.h"// _Py_GET_GLOBAL_OBJECT()
#include "pycore_initconfig.h" // _PyStatus_OK()
#include "pycore_long.h" // _PyLong_DigitValue
+#include "pycore_list.h" // _PyList_GetItemRef
#include "pycore_object.h" // _PyObject_GC_TRACK
#include "pycore_pymem.h" // PYMEM_CLEANBYTE
#include "pycore_strhex.h" // _Py_strhex_with_sep()
Py_ssize_t i, size = PyList_GET_SIZE(x);
Py_ssize_t value;
char *str;
- PyObject *item;
_PyBytesWriter writer;
_PyBytesWriter_Init(&writer);
size = writer.allocated;
for (i = 0; i < PyList_GET_SIZE(x); i++) {
- item = PyList_GET_ITEM(x, i);
- Py_INCREF(item);
+ PyObject *item = _PyList_GetItemRef((PyListObject *)x, i);
+ if (item == NULL) {
+ goto error;
+ }
value = PyNumber_AsSsize_t(item, NULL);
Py_DECREF(item);
if (value == -1 && PyErr_Occurred())