]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
* classobject.c: in instance_lenth, test result of call_object
authorGuido van Rossum <guido@python.org>
Thu, 26 Nov 1992 10:30:26 +0000 (10:30 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 26 Nov 1992 10:30:26 +0000 (10:30 +0000)
  for exception before using it.  Fixed a few other places where the
  outcome of calling sq_length wasn't tested for exceptions
  (bltinmodule.c, ceval.c).

Objects/classobject.c
Python/bltinmodule.c
Python/ceval.c

index e3b12c68f6e05901456119304844591bc9858654..0661e810c86e0e49c52b98c304493fb5bea0b9d0 100644 (file)
@@ -324,6 +324,8 @@ instance_length(inst)
                return -1;
        res = call_object(func, (object *)NULL);
        DECREF(func);
+       if (res == NULL)
+               return -1;
        if (is_intobject(res)) {
                outcome = getintvalue(res);
                if (outcome < 0)
index a6e02bed2d6b6a7d2c18537bfc578618a7d86e01..85fd58ecee582d4dbc5ac09dabc0e90fa05cc876 100644 (file)
@@ -412,6 +412,8 @@ min_max(v, sign)
                return NULL;
        }
        n = (*sq->sq_length)(v);
+       if (n < 0)
+               return NULL;
        if (n == 0) {
                err_setstr(ValueError, "min() or max() of empty sequence");
                return NULL;
index d3a732a62ee880172173df3cf572484027d11e73..86ee6cfc23fe53b237887b8dbd0a712a6016d52c 100644 (file)
@@ -1881,6 +1881,8 @@ loop_subscript(v, w)
        }
        i = getintvalue(w);
        n = (*sq->sq_length)(v);
+       if (n < 0)
+               return NULL; /* Exception */
        if (i >= n)
                return NULL; /* End of loop */
        return (*sq->sq_item)(v, i);