Skip to content

Commit 97bee9a

Browse files
committed
Rearrange error handling
1 parent 2a3e50a commit 97bee9a

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Modules/posixmodule.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13543,18 +13543,19 @@ conv_confname(PyObject *module, PyObject *arg, int *valuep, const char *tablenam
1354313543
{
1354413544
if (PyUnicode_Check(arg)) {
1354513545
PyObject *table = PyObject_GetAttrString(module, tablename);
13546-
if (table != NULL) {
13547-
arg = PyObject_GetItem(table, arg);
13548-
if (arg == NULL) {
13549-
PyErr_SetString(
13550-
PyExc_ValueError, "unrecognized configuration name");
13551-
}
13552-
Py_DECREF(table);
13546+
if (table == NULL) {
13547+
return 0;
1355313548
}
13554-
if (PyErr_Occurred())
13549+
13550+
arg = PyObject_GetItem(table, arg);
13551+
Py_DECREF(table);
13552+
if (arg == NULL) {
13553+
PyErr_SetString(
13554+
PyExc_ValueError, "unrecognized configuration name");
1355513555
return 0;
13556+
}
1355613557
} else {
13557-
Py_INCREF(arg);
13558+
Py_INCREF(arg); // Match the Py_DECREF below.
1355813559
}
1355913560

1356013561
if (PyLong_Check(arg)) {

0 commit comments

Comments
 (0)