From: Victor Stinner Date: Wed, 6 Aug 2025 12:33:28 +0000 (+0200) Subject: Use PyConfig_Get() in frozenmain.c (#137421) X-Git-Tag: v3.15.0a1~766 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3a79a122624bafe27252299b7f47f66a6059f732;p=thirdparty%2FPython%2Fcpython.git Use PyConfig_Get() in frozenmain.c (#137421) Replace private _Py_GetConfig() with public PyConfig_Get(). Remove also explicit PyRuntime initialization, it's not needed. --- diff --git a/Python/frozenmain.c b/Python/frozenmain.c index ec4566bd4f84..3de587c04232 100644 --- a/Python/frozenmain.c +++ b/Python/frozenmain.c @@ -1,8 +1,7 @@ /* Python interpreter main program for frozen scripts */ #include "Python.h" -#include "pycore_pystate.h" // _Py_GetConfig() -#include "pycore_runtime.h" // _PyRuntime_Initialize() +#include "pycore_pystate.h" // _PyInterpreterState_SetRunningMain() #ifdef HAVE_UNISTD_H # include // isatty() @@ -20,11 +19,6 @@ extern int PyInitFrozenExtensions(void); int Py_FrozenMain(int argc, char **argv) { - PyStatus status = _PyRuntime_Initialize(); - if (PyStatus_Exception(status)) { - Py_ExitStatusException(status); - } - PyConfig config; PyConfig_InitPythonConfig(&config); // Suppress errors from getpath.c @@ -32,7 +26,7 @@ Py_FrozenMain(int argc, char **argv) // Don't parse command line options like -E config.parse_argv = 0; - status = PyConfig_SetBytesArgv(&config, argc, argv); + PyStatus status = PyConfig_SetBytesArgv(&config, argc, argv); if (PyStatus_Exception(status)) { PyConfig_Clear(&config); Py_ExitStatusException(status); @@ -64,7 +58,12 @@ Py_FrozenMain(int argc, char **argv) PyWinFreeze_ExeInit(); #endif - if (_Py_GetConfig()->verbose) { + int verbose; + if (PyConfig_GetInt("verbose", &verbose) < 0) { + verbose = 0; + PyErr_Clear(); + } + if (verbose) { fprintf(stderr, "Python %s\n%s\n", Py_GetVersion(), Py_GetCopyright()); }