diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-15 21:20:39 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-08-15 21:20:39 (GMT) |
commit | 721738fbee8d75dab5a5d3c4f3dbd7c72d76925e (patch) | |
tree | c0e693ed7f2e6c44d48555f3cc4d8775ac8e14bb /Modules/itertoolsmodule.c | |
parent | 9351117139363f3e600c541bc88139702a055db8 (diff) | |
parent | 6f430e496339aea3e688165340456b555d5e1035 (diff) | |
download | cpython-721738fbee8d75dab5a5d3c4f3dbd7c72d76925e.zip cpython-721738fbee8d75dab5a5d3c4f3dbd7c72d76925e.tar.gz cpython-721738fbee8d75dab5a5d3c4f3dbd7c72d76925e.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 | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index 194f7fb..9115b67 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -1105,11 +1105,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; } } @@ -1124,7 +1126,7 @@ static PyObject * dropwhile_setstate(dropwhileobject *lz, PyObject *state) { int start = PyObject_IsTrue(state); - if (start == -1) + if (start < 0) return NULL; lz->start = start; Py_RETURN_NONE; @@ -1270,10 +1272,11 @@ takewhile_next(takewhileobject *lz) } ok = PyObject_IsTrue(good); Py_DECREF(good); - if (ok) + if (ok == 1) return item; Py_DECREF(item); - lz->stop = 1; + if (ok == 0) + lz->stop = 1; return NULL; } @@ -1288,7 +1291,7 @@ static PyObject * takewhile_reduce_setstate(takewhileobject *lz, PyObject *state) { int stop = PyObject_IsTrue(state); - if (stop == -1) + if (stop < 0) return NULL; lz->stop = stop; Py_RETURN_NONE; @@ -3536,7 +3539,7 @@ compress_next(compressobject *lz) if (ok == 1) return datum; Py_DECREF(datum); - if (ok == -1) + if (ok < 0) return NULL; } } @@ -3692,9 +3695,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; } } |