I went with the easiest solution: just removing the offending line. See the issue description with my reasoning.
https://github.com/python/cpython/issues/101609
clear_module_state(module_state *state)
{
/* heap types */
- (void)_PyCrossInterpreterData_UnregisterClass(state->ChannelIDType);
+ if (state->ChannelIDType != NULL) {
+ (void)_PyCrossInterpreterData_UnregisterClass(state->ChannelIDType);
+ }
Py_CLEAR(state->ChannelIDType);
/* exceptions */
return 0;
error:
- (void)_PyCrossInterpreterData_UnregisterClass(state->ChannelIDType);
_globals_fini();
return -1;
}