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:
Victor Stinner 2017-11-25 00:01:23 +01:00 committed by GitHub
parent 46972b7bc3
commit f04ebe2a4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 96 additions and 70 deletions

View file

@ -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
}