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:
Itamar Oren 2025-11-14 01:43:25 -08:00 committed by GitHub
parent a4dd66275b
commit 1e4e59bb37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 223 additions and 21 deletions

View file

@ -10,6 +10,13 @@ struct _inittab {
PyAPI_DATA(struct _inittab *) PyImport_Inittab;
PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
// Custom importers may use this API to initialize statically linked
// extension modules directly from a spec and init function,
// without needing to go through inittab
PyAPI_FUNC(PyObject *) PyImport_CreateModuleFromInitfunc(
PyObject *spec,
PyObject *(*initfunc)(void));
struct _frozen {
const char *name; /* ASCII encoded string */
const unsigned char *code;