@@ -248,6 +248,24 @@ basic__clear_globals(PyObject *self, PyObject *Py_UNUSED(ignored))
248
248
basic__clear_globals_doc}
249
249
250
250
251
+ PyDoc_STRVAR (basic__clear_module_state_doc , "_clear_module_state()\n\
252
+ \n\
253
+ Free the module state and set it to uninitialized." );
254
+
255
+ static PyObject *
256
+ basic__clear_module_state (PyObject * self , PyObject * Py_UNUSED (ignored )) {
257
+ module_state * state = get_module_state (self );
258
+ if (state != NULL ) {
259
+ clear_state (state );
260
+ }
261
+ Py_RETURN_NONE ;
262
+ }
263
+
264
+ #define _CLEAR_MODULE_STATE_METHODDEF \
265
+ {"_clear_module_state", basic__clear_module_state, METH_NOARGS, \
266
+ basic__clear_module_state_doc}
267
+
268
+
251
269
/*********************************************/
252
270
/* the _testsinglephase module (and aliases) */
253
271
/*********************************************/
@@ -408,7 +426,7 @@ PyInit__testsinglephase_with_reinit(void)
408
426
/* the _testsinglephase_with_state module */
409
427
/******************************************/
410
428
411
- /* This ia less typical of legacy extensions in the wild:
429
+ /* This is a less typical of legacy extensions in the wild:
412
430
- single-phase init (same as _testsinglephase above)
413
431
- has some module state
414
432
- supports repeated initialization
@@ -424,6 +442,7 @@ static PyMethodDef TestMethods_WithState[] = {
424
442
LOOK_UP_SELF_METHODDEF ,
425
443
SUM_METHODDEF ,
426
444
STATE_INITIALIZED_METHODDEF ,
445
+ _CLEAR_MODULE_STATE_METHODDEF ,
427
446
{NULL , NULL } /* sentinel */
428
447
};
429
448
0 commit comments