Use PyConfig_Get() in frozenmain.c (#137421)
Replace private _Py_GetConfig() with public PyConfig_Get(). Remove also explicit PyRuntime initialization, it's not needed.
This commit is contained in:
@@ -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 <unistd.h> // 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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user