gh-111789: Use PyDict_GetItemRef() in Modules/_csv.c (gh-112073)

This commit is contained in:
Serhiy Storchaka 2023-11-27 19:35:52 +02:00 committed by GitHub
parent 4eea1e8236
commit b14e5df120
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 8 deletions

View File

@ -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;
}