summaryrefslogtreecommitdiff
path: root/Python/codecs.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/codecs.c')
-rw-r--r--Python/codecs.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index ff2142df40..d4b34f8397 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -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;
}