Skip to content

Commit c61b9d5

Browse files
committed
conditionally ues PyList_GetItemRef
1 parent 8624af4 commit c61b9d5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/auto_map.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,13 @@ fami_iternext(FAMIObject *self)
426426
else {
427427
PyObject* t = PyTuple_New(2);
428428
if (!t) { return NULL; }
429+
#if PY_VERSION_HEX >= 0x030D0000 // Python 3.13+
429430
PyObject* k = PyList_GetItemRef(self->fam->keys, index);
430-
if (!t) { return NULL; }
431+
#else
432+
PyObject* k = PyList_GET_ITEM(self->fam->keys, index);
433+
Py_XINCREF(k);
434+
#endif
435+
if (!k) { return NULL; }
431436
PyTuple_SET_ITEM(t, 0, k);
432437
PyTuple_SET_ITEM(t, 1, PyLong_FromSsize_t(index));
433438
return t;
@@ -438,7 +443,12 @@ fami_iternext(FAMIObject *self)
438443
return PyArray_ToScalar(PyArray_GETPTR1(self->keys_array, index), self->keys_array);
439444
}
440445
else {
446+
#if PY_VERSION_HEX >= 0x030D0000 // Python 3.13+
441447
PyObject* yield = PyList_GetItemRef(self->fam->keys, index);
448+
#else
449+
PyObject* yield = PyList_GET_ITEM(self->fam->keys, index);
450+
Py_XINCREF(yield);
451+
#endif
442452
if (!yield) { return NULL; }
443453
return yield;
444454
}

0 commit comments

Comments
 (0)