summaryrefslogtreecommitdiffstats
path: root/Python/codecs.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-05-30 14:45:22 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-05-30 14:45:22 (GMT)
commitfa494fd88384acc52cf9292d0c89e2961c8f747f (patch)
treea30958b83189caf872f34e7b94a1aeeef28ed3a9 /Python/codecs.c
parent50451eb91232b0e90c677419db19ed7b33a698a9 (diff)
downloadcpython-fa494fd88384acc52cf9292d0c89e2961c8f747f.zip
cpython-fa494fd88384acc52cf9292d0c89e2961c8f747f.tar.gz
cpython-fa494fd88384acc52cf9292d0c89e2961c8f747f.tar.bz2
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.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index 74445b0..27f2aeb 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;
}
}