diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-15 21:18:25 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-15 21:18:25 (GMT) |
commit | 6f430e496339aea3e688165340456b555d5e1035 (patch) | |
tree | 197393decf924def07e006f3e35cf21f2fec0f08 /Modules/itertoolsmodule.c | |
parent | dd7c55250d67de4d430a0c51dba4f3c0cd8f6ed3 (diff) | |
download | cpython-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 'Modules/itertoolsmodule.c')
-rw-r--r-- | Modules/itertoolsmodule.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 8b6fa85..77e76fe 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -903,11 +903,13 @@ dropwhile_next(dropwhileobject *lz) } ok = PyObject_IsTrue(good); Py_DECREF(good); - if (!ok) { + if (ok == 0) { lz->start = 1; return item; } Py_DECREF(item); + if (ok < 0) + return NULL; } } @@ -1043,10 +1045,11 @@ takewhile_next(takewhileobject *lz) } ok = PyObject_IsTrue(good); Py_DECREF(good); - if (ok) + if (ok > 0) return item; Py_DECREF(item); - lz->stop = 1; + if (ok == 0) + lz->stop = 1; return NULL; } @@ -2959,9 +2962,11 @@ filterfalse_next(filterfalseobject *lz) ok = PyObject_IsTrue(good); Py_DECREF(good); } - if (!ok) + if (ok == 0) return item; Py_DECREF(item); + if (ok < 0) + return NULL; } } |