[issue33042] New 3.7 startup sequence crashes PyInstaller

Nick Coghlan report at bugs.python.org
Mon Mar 12 10:02:34 EDT 2018


Nick Coghlan <ncoghlan at gmail.com> added the comment:

Adding a bit of context from my prior email discussion with Hartmut: CPython actually reads sys.warnoptions at the end of Py_Initialize (its the last thing we do before the function returns).

It also reads sys._xoptions during startup, since that's one way of enabling settings like dev mode and UTF-8 mode.

That means that even though PySys_AddWarnOption and PySys_AddXOption weren't documented as being safe to call before Py_Initialize, they likely *won't* have the desired effect if an embedding application defers calling them until later, and their absence from the list of "safe to call before Py_Initialize" functions was itself a documentation bug.

For 3.8, I'd hoped that the resolution might be as simple as a hard requirement on embedding applications to call PyRuntime_Initialize() before doing *anything* with the C API, but including the "internal/pystate.h" header and adding a call to _PyRuntime_Initialize() wasn't enough to keep the draft test case in my patch from segfaulting :(

----------

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


More information about the Python-bugs-list mailing list