mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-42260: PyConfig_Read() only parses argv once (GH-23168)
The PyConfig_Read() function now only parses PyConfig.argv arguments once: PyConfig.parse_argv is set to 2 after arguments are parsed. Since Python arguments are strippped from PyConfig.argv, parsing arguments twice would parse the application options as Python options. * Rework the PyConfig documentation. * Fix _testinternalcapi.set_config() error handling. * SetConfigTests no longer needs parse_argv=0 when restoring the old configuration.
This commit is contained in:
parent
f3cb814315
commit
dc42af8fd1
6 changed files with 131 additions and 102 deletions
|
@ -253,14 +253,17 @@ test_set_config(PyObject *Py_UNUSED(self), PyObject *dict)
|
|||
PyConfig config;
|
||||
PyConfig_InitIsolatedConfig(&config);
|
||||
if (_PyConfig_FromDict(&config, dict) < 0) {
|
||||
PyConfig_Clear(&config);
|
||||
return NULL;
|
||||
goto error;
|
||||
}
|
||||
if (_PyInterpreterState_SetConfig(&config) < 0) {
|
||||
return NULL;
|
||||
goto error;
|
||||
}
|
||||
PyConfig_Clear(&config);
|
||||
Py_RETURN_NONE;
|
||||
|
||||
error:
|
||||
PyConfig_Clear(&config);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue