mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #15604: Update uses of PyObject_IsTrue() to check for and handle errors correctly.
Patch by Serhiy Storchaka.
This commit is contained in:
commit
721738fbee
10 changed files with 76 additions and 74 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue