mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
gh-111789: Use PyDict_GetItemRef() in Python/codecs.c (gh-112082)
This commit is contained in:
parent
395fd9c180
commit
aa438bdd6d
1 changed files with 4 additions and 5 deletions
|
@ -146,15 +146,14 @@ PyObject *_PyCodec_Lookup(const char *encoding)
|
||||||
PyUnicode_InternInPlace(&v);
|
PyUnicode_InternInPlace(&v);
|
||||||
|
|
||||||
/* First, try to lookup the name in the registry dictionary */
|
/* First, try to lookup the name in the registry dictionary */
|
||||||
PyObject *result = PyDict_GetItemWithError(interp->codec_search_cache, v);
|
PyObject *result;
|
||||||
|
if (PyDict_GetItemRef(interp->codec_search_cache, v, &result) < 0) {
|
||||||
|
goto onError;
|
||||||
|
}
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
Py_INCREF(result);
|
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else if (PyErr_Occurred()) {
|
|
||||||
goto onError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Next, scan the search functions in order of registration */
|
/* Next, scan the search functions in order of registration */
|
||||||
const Py_ssize_t len = PyList_Size(interp->codec_search_path);
|
const Py_ssize_t len = PyList_Size(interp->codec_search_path);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue