diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-10-01 10:26:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-01 10:26:04 (GMT) |
commit | d49f096cc41f57155efe71cd089c29b38c218488 (patch) | |
tree | 1830b017fe1259e6d5cc27390f0331a83b7d8ba2 /Python | |
parent | 938c00ca9e4207a2531041edff2e82490b02047f (diff) | |
download | cpython-d49f096cc41f57155efe71cd089c29b38c218488.zip cpython-d49f096cc41f57155efe71cd089c29b38c218488.tar.gz cpython-d49f096cc41f57155efe71cd089c29b38c218488.tar.bz2 |
bpo-38304: PyConfig_InitPythonConfig() cannot fail anymore (GH-16509)
PyConfig_InitPythonConfig() and PyConfig_InitIsolatedConfig() no
longer return PyStatus: they cannot fail anymore.
(cherry picked from commit 8462a4936b3a551dc546a6adea04a70b0a07ca67)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
Diffstat (limited to 'Python')
-rw-r--r-- | Python/frozenmain.c | 6 | ||||
-rw-r--r-- | Python/initconfig.c | 31 | ||||
-rw-r--r-- | Python/pathconfig.c | 9 | ||||
-rw-r--r-- | Python/pylifecycle.c | 12 | ||||
-rw-r--r-- | Python/pystate.c | 9 |
5 files changed, 13 insertions, 54 deletions
diff --git a/Python/frozenmain.c b/Python/frozenmain.c index c56938a..7f9cc19 100644 --- a/Python/frozenmain.c +++ b/Python/frozenmain.c @@ -40,11 +40,7 @@ Py_FrozenMain(int argc, char **argv) } PyConfig config; - status = PyConfig_InitPythonConfig(&config); - if (PyStatus_Exception(status)) { - PyConfig_Clear(&config); - Py_ExitStatusException(status); - } + PyConfig_InitPythonConfig(&config); config.pathconfig_warnings = 0; /* Suppress errors from getpath.c */ if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') diff --git a/Python/initconfig.c b/Python/initconfig.c index 9164c7c..a41a329 100644 --- a/Python/initconfig.c +++ b/Python/initconfig.c @@ -569,7 +569,7 @@ PyConfig_Clear(PyConfig *config) } -PyStatus +void _PyConfig_InitCompatConfig(PyConfig *config) { memset(config, 0, sizeof(*config)); @@ -603,17 +603,13 @@ _PyConfig_InitCompatConfig(PyConfig *config) #ifdef MS_WINDOWS config->legacy_windows_stdio = -1; #endif - return _PyStatus_OK(); } -static PyStatus +static void config_init_defaults(PyConfig *config) { - PyStatus status = _PyConfig_InitCompatConfig(config); - if (_PyStatus_EXCEPTION(status)) { - return status; - } + _PyConfig_InitCompatConfig(config); config->isolated = 0; config->use_environment = 1; @@ -632,35 +628,24 @@ config_init_defaults(PyConfig *config) #ifdef MS_WINDOWS config->legacy_windows_stdio = 0; #endif - return _PyStatus_OK(); } -PyStatus +void PyConfig_InitPythonConfig(PyConfig *config) { - PyStatus status = config_init_defaults(config); - if (_PyStatus_EXCEPTION(status)) { - _PyStatus_UPDATE_FUNC(status); - return status; - } + config_init_defaults(config); config->_config_init = (int)_PyConfig_INIT_PYTHON; config->configure_c_stdio = 1; config->parse_argv = 1; - - return _PyStatus_OK(); } -PyStatus +void PyConfig_InitIsolatedConfig(PyConfig *config) { - PyStatus status = config_init_defaults(config); - if (_PyStatus_EXCEPTION(status)) { - _PyStatus_UPDATE_FUNC(status); - return status; - } + config_init_defaults(config); config->_config_init = (int)_PyConfig_INIT_ISOLATED; config->isolated = 1; @@ -675,8 +660,6 @@ PyConfig_InitIsolatedConfig(PyConfig *config) #ifdef MS_WINDOWS config->legacy_windows_stdio = 0; #endif - - return _PyStatus_OK(); } diff --git a/Python/pathconfig.c b/Python/pathconfig.c index ff4bbf2..7f3fdcc 100644 --- a/Python/pathconfig.c +++ b/Python/pathconfig.c @@ -432,16 +432,11 @@ _PyConfig_InitPathConfig(PyConfig *config) static PyStatus pathconfig_global_read(_PyPathConfig *pathconfig) { - PyStatus status; PyConfig config; - - status = _PyConfig_InitCompatConfig(&config); - if (_PyStatus_EXCEPTION(status)) { - goto done; - } + _PyConfig_InitCompatConfig(&config); /* Call _PyConfig_InitPathConfig() */ - status = PyConfig_Read(&config); + PyStatus status = PyConfig_Read(&config); if (_PyStatus_EXCEPTION(status)) { goto done; } diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 5174f74..feb9285 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -843,11 +843,7 @@ pyinit_core(_PyRuntimeState *runtime, } PyConfig config; - - status = _PyConfig_InitCompatConfig(&config); - if (_PyStatus_EXCEPTION(status)) { - goto done; - } + _PyConfig_InitCompatConfig(&config); status = _PyConfig_Copy(&config, src_config); if (_PyStatus_EXCEPTION(status)) { @@ -1070,11 +1066,7 @@ Py_InitializeEx(int install_sigs) } PyConfig config; - - status = _PyConfig_InitCompatConfig(&config); - if (_PyStatus_EXCEPTION(status)) { - Py_ExitStatusException(status); - } + _PyConfig_InitCompatConfig(&config); config.install_signal_handlers = install_sigs; diff --git a/Python/pystate.c b/Python/pystate.c index 098280d..aba673c 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -206,14 +206,7 @@ PyInterpreterState_New(void) interp->id_refcount = -1; interp->check_interval = 100; - PyStatus status = PyConfig_InitPythonConfig(&interp->config); - if (_PyStatus_EXCEPTION(status)) { - /* Don't report status to caller: PyConfig_InitPythonConfig() - can only fail with a memory allocation error. */ - PyConfig_Clear(&interp->config); - PyMem_RawFree(interp); - return NULL; - } + PyConfig_InitPythonConfig(&interp->config); interp->eval_frame = _PyEval_EvalFrameDefault; #ifdef HAVE_DLOPEN |