mirror of https://github.com/python/cpython
gh-111789: Use PyDict_GetItemRef() in Modules/_csv.c (gh-112073)
This commit is contained in:
parent
4eea1e8236
commit
b14e5df120
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue