summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-11-05 17:58:07 (GMT)
committerGitHub <noreply@github.com>2020-11-05 17:58:07 (GMT)
commitdc42af8fd16b10127ce1fc93c13bc1bfd2674aa2 (patch)
tree4d45407632e738acb07a54af480d16c7fadef8b4 /Modules
parentf3cb81431574453aac3b6dcadb3120331e6a8f1c (diff)
downloadcpython-dc42af8fd16b10127ce1fc93c13bc1bfd2674aa2.zip
cpython-dc42af8fd16b10127ce1fc93c13bc1bfd2674aa2.tar.gz
cpython-dc42af8fd16b10127ce1fc93c13bc1bfd2674aa2.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testinternalcapi.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index be144bf..df4725e 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -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;
}