diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-30 17:45:22 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-05-30 17:45:22 +0300 |
commit | b6574f2b45715eec7d9f734f7116a2e370c8561c (patch) | |
tree | f2e0e4f19dfdc5e1b2661e2b899a8622899e0c8f /Python/codecs.c | |
parent | 0394f2b5e5dd2524bbaf35ab3cc569cedcd56e2b (diff) | |
download | cpython-b6574f2b45715eec7d9f734f7116a2e370c8561c.tar.gz |
Issue #24115: Update uses of PyObject_IsTrue(), PyObject_Not(),
PyObject_IsInstance(), PyObject_RichCompareBool() and _PyDict_Contains()
to check for and handle errors correctly.
Diffstat (limited to 'Python/codecs.c')
-rw-r--r-- | Python/codecs.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Python/codecs.c b/Python/codecs.c index 74445b03dc..27f2aebf82 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -549,12 +549,13 @@ PyObject * _PyCodec_LookupTextEncoding(const char *encoding, } else { is_text_codec = PyObject_IsTrue(attr); Py_DECREF(attr); - if (!is_text_codec) { + if (is_text_codec <= 0) { Py_DECREF(codec); - PyErr_Format(PyExc_LookupError, - "'%.400s' is not a text encoding; " - "use %s to handle arbitrary codecs", - encoding, alternate_command); + if (!is_text_codec) + PyErr_Format(PyExc_LookupError, + "'%.400s' is not a text encoding; " + "use %s to handle arbitrary codecs", + encoding, alternate_command); return NULL; } } |