mirror of
https://github.com/python/cpython.git
synced 2025-12-04 16:43:27 +00:00
PyObject_IsTrue() can return an error condition.
Adding code to handle it properly.
This commit is contained in:
parent
863983e8e5
commit
9a9c436036
1 changed files with 4 additions and 1 deletions
|
|
@ -213,6 +213,7 @@ random_seed(RandomObject *self, PyObject *args)
|
||||||
unsigned long *key = NULL;
|
unsigned long *key = NULL;
|
||||||
unsigned long keymax; /* # of allocated slots in key */
|
unsigned long keymax; /* # of allocated slots in key */
|
||||||
unsigned long keyused; /* # of used slots in key */
|
unsigned long keyused; /* # of used slots in key */
|
||||||
|
int err;
|
||||||
|
|
||||||
PyObject *arg = NULL;
|
PyObject *arg = NULL;
|
||||||
|
|
||||||
|
|
@ -261,11 +262,13 @@ random_seed(RandomObject *self, PyObject *args)
|
||||||
thirtytwo = PyInt_FromLong(32L);
|
thirtytwo = PyInt_FromLong(32L);
|
||||||
if (thirtytwo == NULL)
|
if (thirtytwo == NULL)
|
||||||
goto Done;
|
goto Done;
|
||||||
while (PyObject_IsTrue(n)) {
|
while ((err=PyObject_IsTrue(n))) {
|
||||||
PyObject *newn;
|
PyObject *newn;
|
||||||
PyObject *pychunk;
|
PyObject *pychunk;
|
||||||
unsigned long chunk;
|
unsigned long chunk;
|
||||||
|
|
||||||
|
if (err == -1)
|
||||||
|
goto Done;
|
||||||
pychunk = PyNumber_And(n, masklower);
|
pychunk = PyNumber_And(n, masklower);
|
||||||
if (pychunk == NULL)
|
if (pychunk == NULL)
|
||||||
goto Done;
|
goto Done;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue