summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-10-01 10:06:16 (GMT)
committerGitHub <noreply@github.com>2019-10-01 10:06:16 (GMT)
commit8462a4936b3a551dc546a6adea04a70b0a07ca67 (patch)
tree3c4655f174d1aa9abcdb5226532db0e4d7434bca /Python
parent3c30a76f3d3c0dcc1fb4de097fa4a3a4c92c0b0b (diff)
downloadcpython-8462a4936b3a551dc546a6adea04a70b0a07ca67.zip
cpython-8462a4936b3a551dc546a6adea04a70b0a07ca67.tar.gz
cpython-8462a4936b3a551dc546a6adea04a70b0a07ca67.tar.bz2
bpo-38304: PyConfig_InitPythonConfig() cannot fail anymore (GH-16509)
PyConfig_InitPythonConfig() and PyConfig_InitIsolatedConfig() no longer return PyStatus: they cannot fail anymore.
Diffstat (limited to 'Python')
-rw-r--r--Python/frozenmain.c6
-rw-r--r--Python/initconfig.c31
-rw-r--r--Python/pathconfig.c9
-rw-r--r--Python/pylifecycle.c12
-rw-r--r--Python/pystate.c9
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 107429c..caa9bf5 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 5550194..61408e1 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 019c56c..add7519 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -847,11 +847,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)) {
@@ -1073,11 +1069,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 69b86ce..f3d89e7 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -205,14 +205,7 @@ PyInterpreterState_New(void)
memset(interp, 0, sizeof(*interp));
interp->id_refcount = -1;
- 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