@@ -436,13 +436,13 @@ optionally followed by an import of the module::
436
436
437
437
.. note ::
438
438
439
- If you define * static * extension types rather than heap-allocated types,
440
- the module can cause the same problems as the legacy single-phase
441
- initialization when removing entries from ``sys.modules `` or importing
442
- compiled modules into multiple interpreters within a process
443
- (or following a :c:func: ` fork ` without an intervening :c:func: `exec `).
444
- In this case, at least the module should reject subinterpreters by using
445
- a :c:type: ` PyModuleDef_Slot ` (`` Py_mod_multiple_interpreters ` `).
439
+ If you declare a global variable or a local static one, the module can
440
+ cause the same problems as the legacy single-phase initialization when
441
+ removing entries from ``sys.modules `` or importing compiled modules into
442
+ multiple interpreters within a process (or following a :c:func: ` fork ` without an
443
+ intervening :c:func: `exec `). In this case, at least the module should
444
+ stop supporting subinterpreters through a :c:type: ` PyModuleDef_Slot `
445
+ ( :c:data: ` Py_mod_multiple_interpreters `).
446
446
447
447
A more substantial example module is included in the Python source distribution
448
448
as :file: `Modules/xxlimited.c `. This file may be used as a template or simply
@@ -1279,6 +1279,8 @@ function must take care of initializing the C API pointer array::
1279
1279
1280
1280
static PyModuleDef_Slot spam_module_slots[] = {
1281
1281
{Py_mod_exec, spam_module_exec},
1282
+ // Just use this while using a local static variable
1283
+ {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
1282
1284
{0, NULL}
1283
1285
};
1284
1286
0 commit comments