diff options
author | Raymond Hettinger <python@rcn.com> | 2003-04-23 00:14:18 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-04-23 00:14:18 (GMT) |
commit | 9a9c436036dbd25d6ae42f67f22ccc5549b3c092 (patch) | |
tree | b02146560754f7bbeb2a77331512e00b6bce284e | |
parent | 863983e8e54a32bfddc8e6213e7871d42125928f (diff) | |
download | cpython-9a9c436036dbd25d6ae42f67f22ccc5549b3c092.zip cpython-9a9c436036dbd25d6ae42f67f22ccc5549b3c092.tar.gz cpython-9a9c436036dbd25d6ae42f67f22ccc5549b3c092.tar.bz2 |
PyObject_IsTrue() can return an error condition.
Adding code to handle it properly.
-rw-r--r-- | Modules/_randommodule.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index 00863b6..1a004a9 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -213,6 +213,7 @@ random_seed(RandomObject *self, PyObject *args) unsigned long *key = NULL; unsigned long keymax; /* # of allocated slots in key */ unsigned long keyused; /* # of used slots in key */ + int err; PyObject *arg = NULL; @@ -261,11 +262,13 @@ random_seed(RandomObject *self, PyObject *args) thirtytwo = PyInt_FromLong(32L); if (thirtytwo == NULL) goto Done; - while (PyObject_IsTrue(n)) { + while ((err=PyObject_IsTrue(n))) { PyObject *newn; PyObject *pychunk; unsigned long chunk; + if (err == -1) + goto Done; pychunk = PyNumber_And(n, masklower); if (pychunk == NULL) goto Done; |