[libgpiod][PATCH 8/9] bindings: python: tests: migrate the system module to multi-phase init

Vincent Fazio
2026-04-22T01:21:04Z

Single-phase initialization has been classified as legacy within CPython
documentation [0] with multi-phase being its successor [1].

As such, switch to the new methodology.

[0]: https://docs.python.org/3/c-api/extension-modules.html#legacy-single-phase-initialization
[1]: https://docs.python.org/3/c-api/extension-modules.html#multi-phase-initialization

Signed-off-by: Vincent Fazio <vfazio@gmail.com>
---
bindings/python/tests/system/ext.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bindings/python/tests/system/ext.c b/bindings/python/tests/system/ext.c
index c982fa6..800648e 100644
--- a/bindings/python/tests/system/ext.c
+++ b/bindings/python/tests/system/ext.c
@@ -67,13 +67,18 @@ static PyMethodDef module_methods[] = {
{ }
};

+static struct PyModuleDef_Slot module_slots[] = {
+ {0, NULL},
+};
+
static PyModuleDef module_def = {
PyModuleDef_HEAD_INIT,
.m_name = "system._ext",
.m_methods = module_methods,
+ .m_slots = module_slots,
};

PyMODINIT_FUNC PyInit__ext(void)
{
- return PyModule_Create(&module_def);
+ return PyModuleDef_Init(&module_def);
}
--
2.43.0