Skip to content

Commit

Permalink
pythongh-111789: Use PyDict_GetItemRef() in Modules/_csv.c (pythongh-…
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored and Glyphack committed Jan 27, 2024
1 parent 750b99b commit 2973bc9
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,9 @@ static PyObject *
get_dialect_from_registry(PyObject *name_obj, _csvstate *module_state)
{
PyObject *dialect_obj;

dialect_obj = PyDict_GetItemWithError(module_state->dialects, name_obj);
if (dialect_obj == NULL) {
if (!PyErr_Occurred())
PyErr_Format(module_state->error_obj, "unknown dialect");
if (PyDict_GetItemRef(module_state->dialects, name_obj, &dialect_obj) == 0) {
PyErr_SetString(module_state->error_obj, "unknown dialect");
}
else
Py_INCREF(dialect_obj);

return dialect_obj;
}

Expand Down

0 comments on commit 2973bc9

Please sign in to comment.