summaryrefslogtreecommitdiffhomepage
path: root/src/python
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2022-12-30 00:07:20 +0000
committerAndrew Clayton <a.clayton@nginx.com>2022-12-30 00:07:20 +0000
commitfcbb26e92af4cab8877ff5dc39b787377e5ce253 (patch)
tree60262cefcde0233a9758d239301b8e2ae84767e5 /src/python
parent2596a8952720bb8503430eda3b4560435fd7b71e (diff)
downloadunit-fcbb26e92af4cab8877ff5dc39b787377e5ce253.tar.gz
unit-fcbb26e92af4cab8877ff5dc39b787377e5ce253.tar.bz2
Python: Do some cleanup in nxt_python3_init_config().
This is a preparatory patch for future work and cleans up the code a little in the Python 3.8+ variant of nxt_python3_init_config(). The main advantage being we no longer have calls to PyConfig_Clear() in two different paths. The variables have a little extra space in their declarations to allow for the next patch which introduces a variable with a longer type name, which will help reduce the size of the diff. Reviewed-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src/python')
-rw-r--r--src/python/nxt_python.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/python/nxt_python.c b/src/python/nxt_python.c
index bdb04579..83f2544e 100644
--- a/src/python/nxt_python.c
+++ b/src/python/nxt_python.c
@@ -75,8 +75,11 @@ static nxt_python_proto_t nxt_py_proto;
static nxt_int_t
nxt_python3_init_config(nxt_int_t pep405)
{
- PyStatus status;
- PyConfig config;
+ PyConfig config;
+ PyStatus status;
+ nxt_int_t ret;
+
+ ret = NXT_ERROR;
PyConfig_InitIsolatedConfig(&config);
@@ -84,29 +87,28 @@ nxt_python3_init_config(nxt_int_t pep405)
status = PyConfig_SetString(&config, &config.program_name,
nxt_py_home);
if (PyStatus_Exception(status)) {
- goto pyinit_exception;
+ goto out_config_clear;
}
} else {
- status =PyConfig_SetString(&config, &config.home, nxt_py_home);
+ status = PyConfig_SetString(&config, &config.home, nxt_py_home);
if (PyStatus_Exception(status)) {
- goto pyinit_exception;
+ goto out_config_clear;
}
}
status = Py_InitializeFromConfig(&config);
if (PyStatus_Exception(status)) {
- goto pyinit_exception;
+ goto out_config_clear;
}
- PyConfig_Clear(&config);
- return NXT_OK;
+ ret = NXT_OK;
-pyinit_exception:
+out_config_clear:
PyConfig_Clear(&config);
- return NXT_ERROR;
+ return ret;
}
#elif PY_MAJOR_VERSION == 3