From 3af55474437c16199549e42e0842f9713e80055d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 5 Nov 2026 01:10:40 +0100 Subject: [PATCH] gh-161185: Fix test_cext: replace PyType_FromSlots() with PyType_FromSpec() Replace PyType_FromSlots() with PyType_FromSpec(), and replace PySlot with PyType_Spec. Python 3.14 doesn't support PyType_FromSlots(), it has been added to Python 3.15. --- Lib/test/test_cext/extension.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_cext/extension.c b/Lib/test/test_cext/extension.c index 20df15998e4b852..a67c4afa782cf19 100644 --- a/Lib/test/test_cext/extension.c +++ b/Lib/test/test_cext/extension.c @@ -172,26 +172,32 @@ xsetref_strict_aliasing(PyTypeObject **a, PyTypeObject **b, Py_XSETREF(*b, second); } +static PyType_Slot empty_type_slots[] = { + {0, 0}, +}; + +static PyType_Spec setref_type_spec = { + STR(MODULE_NAME) ".setref_type", // .name + 0, // .basicsize + 0, // .itemsize + Py_TPFLAGS_DEFAULT, // .flags + empty_type_slots, // .slots +}; // gh-161185: Test that Py_SETREF(), Py_XSETREF() and Py_CLEAR() macros // have no strict aliasing issue static PyObject * test_setref_strict_aliasing(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args)) { - PySlot slots[] = { - PySlot_PTR_STATIC(Py_tp_name, STR(MODULE_NAME) ".setref_type"), - PySlot_PTR_STATIC(Py_tp_flags, Py_TPFLAGS_DEFAULT), - PySlot_END - }; PyObject *first, *second; Py_ssize_t first_refcnt, second_refcnt; PyTypeObject *slot = NULL; - first = PyType_FromSlots(slots); + first = PyType_FromSpec(&setref_type_spec); if (first == NULL) { return NULL; } - second = PyType_FromSlots(slots); + second = PyType_FromSpec(&setref_type_spec); if (second == NULL) { Py_DECREF(first); return NULL;