Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 78604:56dc7b09f390 3.2
Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Wed, 15 Aug 2012 23:18:25 +0200 |
| parents | 9de4d85e4197 |
| children | 1856d57abfc8 b878df1d23b1 |
line wrap: on
line diff
--- a/Python/import.c Wed Aug 15 21:37:35 2012 +0200 +++ b/Python/import.c Wed Aug 15 23:18:25 2012 +0200 @@ -1338,7 +1338,10 @@ 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 @@ } 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; }
