Skip to content

Commit b14e5df

Browse files
gh-111789: Use PyDict_GetItemRef() in Modules/_csv.c (gh-112073)
1 parent 4eea1e8 commit b14e5df

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

Modules/_csv.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,9 @@ static PyObject *
160160
get_dialect_from_registry(PyObject *name_obj, _csvstate *module_state)
161161
{
162162
PyObject *dialect_obj;
163-
164-
dialect_obj = PyDict_GetItemWithError(module_state->dialects, name_obj);
165-
if (dialect_obj == NULL) {
166-
if (!PyErr_Occurred())
167-
PyErr_Format(module_state->error_obj, "unknown dialect");
163+
if (PyDict_GetItemRef(module_state->dialects, name_obj, &dialect_obj) == 0) {
164+
PyErr_SetString(module_state->error_obj, "unknown dialect");
168165
}
169-
else
170-
Py_INCREF(dialect_obj);
171-
172166
return dialect_obj;
173167
}
174168

0 commit comments

Comments
 (0)