C API: Cython 3.0 uses private functions removed in Python 3.13 (numpy 1.25.1 fails to build) · Issue #107076 · python/cpython (original) (raw)

numpy 1.25.1 fails to build on Python 3.13: Cython uses private C API removed in Python 3.13. Example of build errors.

I open an issue since Python 3.13 does not provide obvious replacement for these removed functions.

(1) Cython uses removed _PyInterpreterState_GetConfig():

static void __Pyx_init_assertions_enabled(void) { __pyx_assertions_enabled_flag = ! _PyInterpreterState_GetConfig(__Pyx_PyThreadState_Current->interp)->optimization_level; }

(2) Cython uses removed _PyVectorcall_Function() in __Pyx_PyObject_FastCallDict():

static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject **args, size_t _nargs, PyObject *kwargs) { .. #if CYTHON_VECTORCALL vectorcallfunc f = _PyVectorcall_Function(func); if (f) { return f(func, args, (size_t)nargs, kwargs); } ... }

(3) Cython uses removed _PyUnicode_FastCopyCharacters() in __Pyx_PyUnicode_ConcatInPlaceImpl()

static CYTHON_INLINE PyObject *__Pyx_PyUnicode_ConcatInPlaceImpl(PyObject **p_left, PyObject right #if CYTHON_REFNANNY , void __pyx_refnanny #endif ) { ... // copy 'right' into the newly allocated area of 'left' _PyUnicode_FastCopyCharacters(*p_left, left_len, right, 0, right_len); return *p_left; ... }

But also in __Pyx_PyUnicode_Join():

static PyObject* __Pyx_PyUnicode_Join(PyObject* value_tuple, Py_ssize_t value_count, Py_ssize_t result_ulength, Py_UCS4 max_char) { ... #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030300F0 || defined(_PyUnicode_FastCopyCharacters) _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength); #else ... }