@@ -248,6 +248,25 @@ 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
+ {
258
+ module_state * state = get_module_state (self );
259
+ if (state != NULL ) {
260
+ clear_state (state );
261
+ }
262
+ Py_RETURN_NONE ;
263
+ }
264
+
265
+ #define _CLEAR_MODULE_STATE_METHODDEF \
266
+ {"_clear_module_state", basic__clear_module_state, METH_NOARGS, \
267
+ basic__clear_module_state_doc}
268
+
269
+
251
270
/*********************************************/
252
271
/* the _testsinglephase module (and aliases) */
253
272
/*********************************************/
@@ -408,7 +427,7 @@ PyInit__testsinglephase_with_reinit(void)
408
427
/* the _testsinglephase_with_state module */
409
428
/******************************************/
410
429
411
- /* This ia less typical of legacy extensions in the wild:
430
+ /* This is less typical of legacy extensions in the wild:
412
431
- single-phase init (same as _testsinglephase above)
413
432
- has some module state
414
433
- supports repeated initialization
@@ -424,6 +443,7 @@ static PyMethodDef TestMethods_WithState[] = {
424
443
LOOK_UP_SELF_METHODDEF ,
425
444
SUM_METHODDEF ,
426
445
STATE_INITIALIZED_METHODDEF ,
446
+ _CLEAR_MODULE_STATE_METHODDEF ,
427
447
{NULL , NULL } /* sentinel */
428
448
};
429
449
0 commit comments