[issue34008] Do we support calling Py_Main() after Py_Initialize()?

STINNER Victor report at bugs.python.org
Thu Jul 12 11:27:04 EDT 2018


STINNER Victor <vstinner at redhat.com> added the comment:

I tested fontforge. It became clear to me that the fontforge must be able to call Py_Initialize() and only later call Py_Main(). fontforge calls Py_Initialize() and then uses the Python API:

/* This is called to start up the embedded python interpreter */
void FontForge_InitializeEmbeddedPython(void) {
    // static int python_initialized is declared above.
    if ( python_initialized )
	return;

    SetPythonProgramName("fontforge");
    RegisterAllPyModules();
    Py_Initialize();
    python_initialized = 1;

    /* The embedded python interpreter is now functionally
     * "running". We can modify it to our needs.
     */
    CreateAllPyModules();
    InitializePythonMainNamespace();
}

Py_Main() is called after FontForge_InitializeEmbeddedPython().

To be clear, Py_Main() must be fixed in Python 3.7 to apply properly the new configuration, or *at least* define sys.argv.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34008>
_______________________________________


More information about the Python-bugs-list mailing list