diff options
Diffstat (limited to 'Python/codecs.c')
-rw-r--r-- | Python/codecs.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Python/codecs.c b/Python/codecs.c index 18edfbdab9..223ccca603 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -540,15 +540,11 @@ PyObject * _PyCodec_LookupTextEncoding(const char *encoding, * attribute. */ if (!PyTuple_CheckExact(codec)) { - attr = _PyObject_GetAttrId(codec, &PyId__is_text_encoding); - if (attr == NULL) { - if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - } else { - Py_DECREF(codec); - return NULL; - } - } else { + if (_PyObject_LookupAttrId(codec, &PyId__is_text_encoding, &attr) < 0) { + Py_DECREF(codec); + return NULL; + } + if (attr != NULL) { is_text_codec = PyObject_IsTrue(attr); Py_DECREF(attr); if (is_text_codec <= 0) { |