mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-116146: Add C-API to create module from spec and initfunc (GH-139196)
Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
a4dd66275b
commit
1e4e59bb37
7 changed files with 223 additions and 21 deletions
|
|
@ -333,3 +333,24 @@ Importing Modules
|
|||
strings instead of Python :class:`str` objects.
|
||||
|
||||
.. versionadded:: 3.14
|
||||
|
||||
.. c:function:: PyObject* PyImport_CreateModuleFromInitfunc(PyObject *spec, PyObject* (*initfunc)(void))
|
||||
|
||||
This function is a building block that enables embedders to implement
|
||||
the :py:meth:`~importlib.abc.Loader.create_module` step of custom
|
||||
static extension importers (e.g. of statically-linked extensions).
|
||||
|
||||
*spec* must be a :class:`~importlib.machinery.ModuleSpec` object.
|
||||
|
||||
*initfunc* must be an :ref:`initialization function <extension-export-hook>`,
|
||||
the same as for :c:func:`PyImport_AppendInittab`.
|
||||
|
||||
On success, create and return a module object.
|
||||
This module will not be initialized; call :c:func:`!PyModule_Exec`
|
||||
to initialize it.
|
||||
(Custom importers should do this in their
|
||||
:py:meth:`~importlib.abc.Loader.exec_module` method.)
|
||||
|
||||
On error, return NULL with an exception set.
|
||||
|
||||
.. versionadded:: next
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue