Message320758
| Author |
ncoghlan |
| Recipients |
eric.snow, ncoghlan, vstinner |
| Date |
2018年06月30日.06:58:40 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1530341921.37.0.56676864532.issue34008@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
In the current documentation, Py_Main is listed as a regular C API function: https://docs.python.org/3/c-api/veryhigh.html#c.Py_Main
We also didn't add Py_Main() to https://docs.python.org/3/c-api/init.html#before-python-initialization 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 |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2018年06月30日 06:58:41 | ncoghlan | set | recipients:
+ ncoghlan, vstinner, eric.snow |
| 2018年06月30日 06:58:41 | ncoghlan | set | messageid: <1530341921.37.0.56676864532.issue34008@psf.upfronthosting.co.za> |
| 2018年06月30日 06:58:41 | ncoghlan | link | issue34008 messages |
| 2018年06月30日 06:58:40 | ncoghlan | create |
|