Skip to content

Commit 3a79a12

Browse files
authored
Use PyConfig_Get() in frozenmain.c (#137421)
Replace private _Py_GetConfig() with public PyConfig_Get(). Remove also explicit PyRuntime initialization, it's not needed.
1 parent 781eb1a commit 3a79a12

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Python/frozenmain.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* Python interpreter main program for frozen scripts */
22

33
#include "Python.h"
4-
#include "pycore_pystate.h" // _Py_GetConfig()
5-
#include "pycore_runtime.h" // _PyRuntime_Initialize()
4+
#include "pycore_pystate.h" // _PyInterpreterState_SetRunningMain()
65

76
#ifdef HAVE_UNISTD_H
87
# include <unistd.h> // isatty()
@@ -20,19 +19,14 @@ extern int PyInitFrozenExtensions(void);
2019
int
2120
Py_FrozenMain(int argc, char **argv)
2221
{
23-
PyStatus status = _PyRuntime_Initialize();
24-
if (PyStatus_Exception(status)) {
25-
Py_ExitStatusException(status);
26-
}
27-
2822
PyConfig config;
2923
PyConfig_InitPythonConfig(&config);
3024
// Suppress errors from getpath.c
3125
config.pathconfig_warnings = 0;
3226
// Don't parse command line options like -E
3327
config.parse_argv = 0;
3428

35-
status = PyConfig_SetBytesArgv(&config, argc, argv);
29+
PyStatus status = PyConfig_SetBytesArgv(&config, argc, argv);
3630
if (PyStatus_Exception(status)) {
3731
PyConfig_Clear(&config);
3832
Py_ExitStatusException(status);
@@ -64,7 +58,12 @@ Py_FrozenMain(int argc, char **argv)
6458
PyWinFreeze_ExeInit();
6559
#endif
6660

67-
if (_Py_GetConfig()->verbose) {
61+
int verbose;
62+
if (PyConfig_GetInt("verbose", &verbose) < 0) {
63+
verbose = 0;
64+
PyErr_Clear();
65+
}
66+
if (verbose) {
6867
fprintf(stderr, "Python %s\n%s\n",
6968
Py_GetVersion(), Py_GetCopyright());
7069
}

0 commit comments

Comments
 (0)