Skip to content

Use PyConfig_Get() in frozenmain.c #137421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions Python/frozenmain.c
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -20,19 +19,14 @@ 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
config.pathconfig_warnings = 0;
// 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);
Expand Down Expand Up @@ -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());
}
Expand Down
Loading