mirror of
https://github.com/python/cpython.git
synced 2025-08-23 02:04:56 +00:00
bpo-35459: Use PyDict_GetItemWithError() instead of PyDict_GetItem(). (GH-11112)
This commit is contained in:
parent
a180b007d9
commit
a24107b04c
31 changed files with 538 additions and 242 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue