--- a/src/segmentlist.c
+++ b/src/segmentlist.c
@@ -240,7 +240,8 @@
 }


-static int pylist_extend(PyListObject *l, PyObject *v)
+#if PY_VERSION_HEX < 0x030D0000
+static int PyList_Extend(PyListObject *l, PyObject *v)
 {
 	if(!PyList_Check(l)) {
 		PyErr_SetObject(PyExc_TypeError, (PyObject *) l);
@@ -252,6 +253,7 @@
 	Py_DECREF(result);
 	return 0;
 }
+#endif


 static PyListObject *segments_SegmentList_New(PyTypeObject *type, PyObject *sequence)
@@ -263,7 +265,7 @@
 	}
 	new = (PyListObject *) type->tp_alloc(type, 0);
 	if(new && sequence)
-		if(pylist_extend(new, sequence)) {
+		if(PyList_Extend(new, sequence)) {
 			Py_DECREF(new);
 			new = NULL;
 		}
@@ -817,7 +819,7 @@
 	/* Faster algorithm when the two lists have very different sizes.
 	 * OK to not test size functions for error return values */
 	if(PySequence_Size(other) > PyList_GET_SIZE(self) / 2) {
-		if(pylist_extend((PyListObject *) self, other))
+		if(PyList_Extend((PyListObject *) self, other))
 			return NULL;
 		return PyObject_CallMethod(self, "coalesce", NULL);
 	}
@@ -988,7 +990,7 @@
 		Py_XDECREF(other);
 		return NULL;
 	}
-	if(pylist_extend((PyListObject *) new, other)) {
+	if(PyList_Extend((PyListObject *) new, other)) {
 		Py_DECREF(new);
 		Py_DECREF(other);
 		return NULL;
