bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)

This commit is contained in:
Serhiy Storchaka 2019-02-25 17:59:46 +02:00 committed by GitHub
parent a180b007d9
commit a24107b04c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 538 additions and 242 deletions

View file

@ -120,12 +120,16 @@ PyObject *_PyCodec_Lookup(const char *encoding)
PyUnicode_InternInPlace(&v);
/* First, try to lookup the name in the registry dictionary */
result = PyDict_GetItem(interp->codec_search_cache, v);
result = PyDict_GetItemWithError(interp->codec_search_cache, v);
if (result != NULL) {
Py_INCREF(result);
Py_DECREF(v);
return result;
}
else if (PyErr_Occurred()) {
Py_DECREF(v);
return NULL;
}
/* Next, scan the search functions in order of registration */
args = PyTuple_New(1);
@ -648,11 +652,13 @@ PyObject *PyCodec_LookupError(const char *name)
if (name==NULL)
name = "strict";
handler = PyDict_GetItemString(interp->codec_error_registry, name);
if (!handler)
PyErr_Format(PyExc_LookupError, "unknown error handler name '%.400s'", name);
else
handler = _PyDict_GetItemStringWithError(interp->codec_error_registry, name);
if (handler) {
Py_INCREF(handler);
}
else if (!PyErr_Occurred()) {
PyErr_Format(PyExc_LookupError, "unknown error handler name '%.400s'", name);
}
return handler;
}