Skip to content

Commit a560cbf

Browse files
committed
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>
1 parent 834c1a2 commit a560cbf

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/python/nxt_python.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,38 +75,40 @@ static nxt_python_proto_t nxt_py_proto;
7575
static nxt_int_t
7676
nxt_python3_init_config(nxt_int_t pep405)
7777
{
78-
PyStatus status;
79-
PyConfig config;
78+
PyConfig config;
79+
PyStatus status;
80+
nxt_int_t ret;
81+
82+
ret = NXT_ERROR;
8083

8184
PyConfig_InitIsolatedConfig(&config);
8285

8386
if (pep405) {
8487
status = PyConfig_SetString(&config, &config.program_name,
8588
nxt_py_home);
8689
if (PyStatus_Exception(status)) {
87-
goto pyinit_exception;
90+
goto out_config_clear;
8891
}
8992

9093
} else {
91-
status =PyConfig_SetString(&config, &config.home, nxt_py_home);
94+
status = PyConfig_SetString(&config, &config.home, nxt_py_home);
9295
if (PyStatus_Exception(status)) {
93-
goto pyinit_exception;
96+
goto out_config_clear;
9497
}
9598
}
9699

97100
status = Py_InitializeFromConfig(&config);
98101
if (PyStatus_Exception(status)) {
99-
goto pyinit_exception;
102+
goto out_config_clear;
100103
}
101-
PyConfig_Clear(&config);
102104

103-
return NXT_OK;
105+
ret = NXT_OK;
104106

105-
pyinit_exception:
107+
out_config_clear:
106108

107109
PyConfig_Clear(&config);
108110

109-
return NXT_ERROR;
111+
return ret;
110112
}
111113

112114
#elif PY_MAJOR_VERSION == 3

0 commit comments

Comments
 (0)