summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-05-30 14:48:19 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-05-30 14:48:19 (GMT)
commitac5569b1fa483c50edca82bab1ab0a8a927ba86a (patch)
tree9eada65cbf98a2158fda4b3a668ad5ee5969f1c5 /Python
parentbf2b3b72d370f866aa5b8f9077ff37e7c53de894 (diff)
parentfa494fd88384acc52cf9292d0c89e2961c8f747f (diff)
downloadcpython-ac5569b1fa483c50edca82bab1ab0a8a927ba86a.zip
cpython-ac5569b1fa483c50edca82bab1ab0a8a927ba86a.tar.gz
cpython-ac5569b1fa483c50edca82bab1ab0a8a927ba86a.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')
-rw-r--r--Python/codecs.c11
-rw-r--r--Python/import.c6
2 files changed, 11 insertions, 6 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index 38b0c2c..596bd80 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -550,12 +550,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;
}
}
diff --git a/Python/import.c b/Python/import.c
index 3e27715..44aae80 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1366,6 +1366,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals,
PyObject *globals = NULL;
PyObject *fromlist = NULL;
PyInterpreterState *interp = PyThreadState_GET()->interp;
+ int has_from;
/* Make sure to use default values so as to not have
PyObject_CallMethodObjArgs() truncate the parameter list because of a
@@ -1596,7 +1597,10 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *given_globals,
}
/* From now on we don't hold the import lock anymore. */
- if (PyObject_Not(fromlist)) {
+ has_from = PyObject_IsTrue(fromlist);
+ if (has_from < 0)
+ goto error;
+ if (!has_from) {
if (level == 0 || PyUnicode_GET_LENGTH(name) > 0) {
PyObject *front = NULL;
PyObject *partition = NULL;