mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
bpo-32030: Add _PyMainInterpreterConfig.program_name (#4548)
* Py_Main() now calls Py_SetProgramName() earlier to be able to get the program name in _PyMainInterpreterConfig_ReadEnv(). * Rename prog to program_name * Rename progpath to program_name
This commit is contained in:
parent
46972b7bc3
commit
f04ebe2a4d
5 changed files with 96 additions and 70 deletions
|
@ -802,6 +802,14 @@ _PyMainInterpreterConfig_Read(_PyMainInterpreterConfig *config)
|
|||
if (config->install_signal_handlers < 0) {
|
||||
config->install_signal_handlers = 1;
|
||||
}
|
||||
|
||||
if (config->program_name == NULL) {
|
||||
config->program_name = _PyMem_RawWcsdup(Py_GetProgramName());
|
||||
if (config->program_name == NULL) {
|
||||
return _Py_INIT_NO_MEMORY();
|
||||
}
|
||||
}
|
||||
|
||||
return _Py_INIT_OK();
|
||||
}
|
||||
|
||||
|
@ -809,10 +817,16 @@ _PyMainInterpreterConfig_Read(_PyMainInterpreterConfig *config)
|
|||
void
|
||||
_PyMainInterpreterConfig_Clear(_PyMainInterpreterConfig *config)
|
||||
{
|
||||
PyMem_RawFree(config->module_search_path_env);
|
||||
config->module_search_path_env = NULL;
|
||||
PyMem_RawFree(config->home);
|
||||
config->home = NULL;
|
||||
#define CLEAR(ATTR) \
|
||||
do { \
|
||||
PyMem_RawFree(ATTR); \
|
||||
ATTR = NULL; \
|
||||
} while (0)
|
||||
|
||||
CLEAR(config->module_search_path_env);
|
||||
CLEAR(config->home);
|
||||
CLEAR(config->program_name);
|
||||
#undef CLEAR
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue