summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-08-15 21:18:25 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-08-15 21:18:25 (GMT)
commit6f430e496339aea3e688165340456b555d5e1035 (patch)
tree197393decf924def07e006f3e35cf21f2fec0f08 /Python/import.c
parentdd7c55250d67de4d430a0c51dba4f3c0cd8f6ed3 (diff)
downloadcpython-6f430e496339aea3e688165340456b555d5e1035.zip
cpython-6f430e496339aea3e688165340456b555d5e1035.tar.gz
cpython-6f430e496339aea3e688165340456b555d5e1035.tar.bz2
Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c
index 598b7e0..beb0eec 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1338,7 +1338,10 @@ load_source_module(char *name, char *pathname, FILE *fp)
name, pathname);
if (cpathname) {
PyObject *ro = PySys_GetObject("dont_write_bytecode");
- if (ro == NULL || !PyObject_IsTrue(ro))
+ int b = (ro == NULL) ? 0 : PyObject_IsTrue(ro);
+ if (b < 0)
+ goto error_exit;
+ if (!b)
write_compiled_module(co, cpathname, &st);
}
}
@@ -2504,7 +2507,13 @@ import_module_level(char *name, PyObject *globals, PyObject *locals,
}
if (fromlist != NULL) {
- if (fromlist == Py_None || !PyObject_IsTrue(fromlist))
+ int b = (fromlist == Py_None) ? 0 : PyObject_IsTrue(fromlist);
+ if (b < 0) {
+ Py_DECREF(tail);
+ Py_DECREF(head);
+ goto error_exit;
+ }
+ if (!b)
fromlist = NULL;
}