8000 gh-111789: Use PyDict_GetItemRef() in Python/codecs.c (gh-112082) · python/cpython@aa438bd · GitHub
[go: up one dir, main page]

Skip to content

Commit aa438bd

Browse files
gh-111789: Use PyDict_GetItemRef() in Python/codecs.c (gh-112082)
1 parent 395fd9c commit aa438bd

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Python/codecs.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,14 @@ PyObject *_PyCodec_Lookup(const char *encoding)
146146
PyUnicode_InternInPlace(&v);
147147

148148
/* First, try to lookup the name in the registry dictionary */
149-
PyObject *result = PyDict_GetItemWithError(interp->codec_search_cache, v);
149+
PyObject *result;
150+
if (PyDict_GetItemRef(interp->codec_search_cache, v, &result) < 0) {
151+
goto onError;
152+
}
150153
if (result != NULL) {
151-
Py_INCREF(result);
152154
Py_DECREF(v);
153155
return result;
154156
}
155-
else if (PyErr_Occurred()) {
156-
goto onError;
157-
}
158157

159158
/* Next, scan the search functions in order of registration */
160159
const Py_ssize_t len = PyList_Size(interp->codec_search_path);

0 commit comments

Comments
 (0)
0