

We should move the call into the detection logic into Programs/python.c so that embedders have to opt-in to detection (many embedding scenarios will prefer to do their own encoding). RE making UnixMain public, I'd rather the core runtime require a known encoding, rather than trying to detect it. Might it be better to go the other way and deprecate calling Main *without* Initialize? That's easy to fix in Programs/python.c, and eventually Main will just be the "standard" startup sequence based on argv and environ, right? I like having the functions you added to parse argv into config, and I like that they are separate from setting sys.argv. See also bpo-36202: Calling Py_DecodeLocale() before _PyPreConfig_Write() can produce mojibake. INADA-san proposed to make the existing _Py_UnixMain() function public. PySys_SetArgvEx() can be called before Py_Initialize(), but arguments passed to this function are not parsed. Maybe we need to add a new "initialization" API which accepts (argc, argv)? I implemented such function in bpo-36142, but added functions are private: I had to fix a regression in Python 3.7 to fix the application called "fontforge". See bpo-34008: "Do we support calling Py_Main() after Py_Initialize()?". I propose to start to emit a deprecation warning when Py_Main() is called after Py_Initialize(): calling Py_Main() alone is just fine. Problem: Py_Initialize() already allocated a lot of memory, and it is no longer possible to change the memory allocator. For example, if "-X dev" is passed on the command line, the memory allocator should be "debug". Py_Main() can get many options from the command line arguments.
#Fontforge fix warnings update#
Technically, Py_Main() could be smarter and only partially update re_config, but. Problem: in this case, "core_config" is copied into re_config anyway, creating an inconsistency.

Only sys.argv and the internal "path configuration" are updated. If Py_Main() is called after Py_Initialize(), the configuration read by Py_Main() is mostly ignored to only keep the configuration read and writen by Py_Initialize(). Deprecate calling Py_Main() after Py_Initialize()? Add Py_InitializeFromArgv()?Ĭreated on 01:08 by vstinner, last changed 14:59 by admin.
