@@ -941,8 +941,15 @@ find and load modules.
941941 The *fullname * argument specifies the name of the module the loader is to
942942 support. The *path * argument is the path to the extension module's file.
943943
944+ Note that, by default, importing an extension module will fail
945+ in subinterpreters if it doesn't implement multi-phase init
946+ (see :pep: `489 `), even if it would otherwise import successfully.
947+
944948 .. versionadded :: 3.3
945949
950+ .. versionchanged :: 3.12
951+ Multi-phase init is now required for use in subinterpreters.
952+
946953 .. attribute :: name
947954
948955 Name of the module the loader supports.
@@ -1248,6 +1255,30 @@ an :term:`importer`.
12481255
12491256 .. versionadded :: 3.7
12501257
1258+ .. function :: _incompatible_extension_module_restrictions(*, disable_check)
1259+
1260+ A context manager that can temporarily skip the compatibility check
1261+ for extension modules. By default the check is enabled and will fail
1262+ when a single-phase init module is imported in a subinterpreter.
1263+ It will also fail for a multi-phase init module that doesn't
1264+ explicitly support a per-interpreter GIL, when imported
1265+ in an interpreter with its own GIL.
1266+
1267+ Note that this function is meant to accommodate an unusual case;
1268+ one which is likely to eventually go away. There's is a pretty good
1269+ chance this is not what you were looking for.
1270+
1271+ You can get the same effect as this function by implementing the
1272+ basic interface of multi-phase init (:pep: `489 `) and lying about
1273+ support for mulitple interpreters (or per-interpreter GIL).
1274+
1275+ .. warning ::
1276+ Using this function to disable the check can lead to
1277+ unexpected behavior and even crashes. It should only be used during
1278+ extension module development.
1279+
1280+ .. versionadded :: 3.12
1281+
12511282.. class :: LazyLoader(loader)
12521283
12531284 A class which postpones the execution of the loader of a module until the
0 commit comments