From 0b0084a4551e7a5c880da36f0fc4b16dab96e4fe Mon Sep 17 00:00:00 2001 From: cody Date: Thu, 20 Aug 2026 18:21:26 +0200 Subject: [PATCH] Declare module to be usable without GIL --- src/bitstruct/c.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/bitstruct/c.c b/src/bitstruct/c.c index c2ea86a..c300e01 100644 --- a/src/bitstruct/c.c +++ b/src/bitstruct/c.c @@ -2605,6 +2605,14 @@ PyMODINIT_FUNC PyInit_c(void) return (NULL); } +#ifdef Py_GIL_DISABLED + if (PyUnstable_Module_SetGIL(module_p, Py_MOD_GIL_NOT_USED) < 0) { + Py_DECREF(module_p); + + return (NULL); + } +#endif + Py_INCREF(&compiled_format_type); if (PyModule_AddObject(module_p, @@ -2616,6 +2624,8 @@ PyMODINIT_FUNC PyInit_c(void) return (NULL); } + Py_INCREF(&compiled_format_dict_type); + if (PyModule_AddObject(module_p, "CompiledFormatDict", (PyObject *)&compiled_format_dict_type) < 0) {