Skip to content

inittab fails on initfunc which creates modules with PyModule_FromSlotsAndSpec #151868

@davidhewitt

Description

@davidhewitt

Bug report

Bug description:

I am looking at updating PyO3 to use PyModule_FromSlotsAndSpec to initialize modules embedded in binaries using PyImport_AppendToInittab.

I can successfully create the module as part of the initfunc, however the loader then fails on the following check:

cpython/Python/importdl.c

Lines 506 to 512 in f5119a5

res.def = _PyModule_GetDefOrNull(m);
if (res.def == NULL) {
PyErr_Clear();
_Py_ext_module_loader_result_set_error(
&res, _Py_ext_module_loader_result_ERR_MISSING_DEF);
goto error;
}

This check is guaranteed to fail, as modules created from slots do not have a PyModuleDef.

CPython versions tested on:

3.15

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions