diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-15 23:16:51 +0200 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-15 23:16:51 +0200 |
commit | c5bef75c77af414c2f6c5901b6838d3071313bc7 (patch) | |
tree | ec54e539c09e4c9b6fc8963258fef4c6484e5573 /Python/import.c | |
parent | 4ffe9a064022b973ab152d108b13c470af486a74 (diff) | |
download | cpython-git-c5bef75c77af414c2f6c5901b6838d3071313bc7.tar.gz |
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.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c index e95b7c0e6f..53c9b293e9 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1043,7 +1043,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); } } @@ -2200,7 +2203,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; } |