From 0501e5f16fe258851a4ac8bf42c271b5d021e634 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sun, 29 Jun 2025 13:41:12 -0700 Subject: [PATCH 1/2] convert: name structs consistently Signed-off-by: Benjamin Gilbert --- openslide/_convert.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openslide/_convert.c b/openslide/_convert.c index 37d6e75..efec39c 100644 --- a/openslide/_convert.c +++ b/openslide/_convert.c @@ -96,22 +96,22 @@ _convert_argb2rgba(PyObject *self, PyObject *args) return ret; } -static PyMethodDef ConvertMethods[] = { +static PyMethodDef _convert_methods[] = { {"argb2rgba", _convert_argb2rgba, METH_VARARGS, "Convert aRGB to RGBA in place."}, {NULL, NULL, 0, NULL} }; -static struct PyModuleDef convertmodule = { +static struct PyModuleDef _convert_module = { PyModuleDef_HEAD_INIT, "_convert", NULL, 0, - ConvertMethods + _convert_methods, }; PyMODINIT_FUNC PyInit__convert(void) { - return PyModule_Create2(&convertmodule, PYTHON_API_VERSION); + return PyModule_Create2(&_convert_module, PYTHON_API_VERSION); } From 442f91ba0b30a2682711be7235efe6d2f64b26d9 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Sun, 29 Jun 2025 13:47:42 -0700 Subject: [PATCH 2/2] convert: switch to multi-phase module initialization Single-phase initialization is considered legacy. Signed-off-by: Benjamin Gilbert --- openslide/_convert.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openslide/_convert.c b/openslide/_convert.c index efec39c..b9422f0 100644 --- a/openslide/_convert.c +++ b/openslide/_convert.c @@ -102,16 +102,21 @@ static PyMethodDef _convert_methods[] = { {NULL, NULL, 0, NULL} }; +static PyModuleDef_Slot _convert_slots[] = { + {0, NULL} +}; + static struct PyModuleDef _convert_module = { PyModuleDef_HEAD_INIT, "_convert", NULL, 0, _convert_methods, + _convert_slots, }; PyMODINIT_FUNC PyInit__convert(void) { - return PyModule_Create2(&_convert_module, PYTHON_API_VERSION); + return PyModuleDef_Init(&_convert_module); }