]> granicus.if.org Git - python/commitdiff
PyObject_IsTrue() can return an error condition.
authorRaymond Hettinger <python@rcn.com>
Wed, 23 Apr 2003 00:14:18 +0000 (00:14 +0000)
committerRaymond Hettinger <python@rcn.com>
Wed, 23 Apr 2003 00:14:18 +0000 (00:14 +0000)
Adding code to handle it properly.

Modules/_randommodule.c

index 00863b6691e3c0e03e045aadd1243e197db0e4fa..1a004a9fe140a37738c7a9f5bfe70742ede5fbbb 100644 (file)
@@ -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;