This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients eric.snow, ncoghlan, vstinner
Date 2018-06-30.06:58:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In the current documentation, Py_Main is listed as a regular C API function:

We also didn't add Py_Main() to when we did the review for "Functions which are safe to call before Py_Initialize()".

If it truly is a regular C API function, then this suggests that Py_Main() should be called *after* Py_Initialize().

However, Py_Main() has historically called Py_Initialize() *itself*, and generally assumes it has total control over management of the current process - it doesn't expect to be sharing the current process with an embedding application.

In Python 3.7, Py_Main() was changed to call _Py_InitializeCore() and _Py_InitializeMainInterpreter() as separate steps, allowing it to detect cases where an embedding application had already called Py_Initialize(), meaning that Py_Main()'s config setting changes wouldn't be applied.

In effect, we've converted a silent failure (settings not read and applied as expected) into a noisy one (attempting to call Py_Main() in an already initialised interpreter).

(The test suite is silent on the matter, since the idea of an embedding application calling Py_Initialize() before calling Py_Main() never even occurred to us)

So the question is, what should we do about this for Python 3.7:

1. Treat it as a regression, try to replicate the old behaviour of partially (but not completely) ignoring the config settings read by Py_Main()
2. Treat it as a regression, but don't try to replicate the old config-settings-are-partially-applied behaviour - just ignore the settings read by Py_Main() completely
3. Treat it as a long standing documentation error, update the docs to make it clear that Py_Main() expects to handle calling Py_Initialize() itself, and update the Python 3.7 porting guide accordingly
Date User Action Args
2018-06-30 06:58:41ncoghlansetrecipients: + ncoghlan, vstinner, eric.snow
2018-06-30 06:58:41ncoghlansetmessageid: <>
2018-06-30 06:58:41ncoghlanlinkissue34008 messages
2018-06-30 06:58:40ncoghlancreate