]> granicus.if.org Git - python/commitdiff
Handle really big steps in extended slices.
authorMichael W. Hudson <mwh@python.net>
Wed, 6 Nov 2002 15:17:32 +0000 (15:17 +0000)
committerMichael W. Hudson <mwh@python.net>
Wed, 6 Nov 2002 15:17:32 +0000 (15:17 +0000)
Fixes a test failure on 64 bit platforms (I hope).

Objects/sliceobject.c
Python/ceval.c

index a035e5faf01262b9e5367f50fc11119829e8a600..7198cca4b1c71d85d166c6a7512815a03371c710 100644 (file)
@@ -121,11 +121,8 @@ PySlice_GetIndicesEx(PySliceObject *r, int length,
                *step = 1;
        } 
        else {
-               *step = PyInt_AsLong(r->step);
-               if (*step == -1 && PyErr_Occurred()) {
-                       return -1;
-               }
-               else if (*step == 0) {
+               if (!_PyEval_SliceIndex(r->step, step)) return -1;
+               if (*step == 0) {
                        PyErr_SetString(PyExc_ValueError,
                                        "slice step cannot be zero");
                        return -1;
index afc480e151e29bcde7a700a1e6670298fa8ffc40..09b88a6ca7806197241e636e95bdb806e3d70811 100644 (file)
@@ -3507,7 +3507,7 @@ _PyEval_SliceIndex(PyObject *v, int *pi)
                if (x > INT_MAX)
                        x = INT_MAX;
                else if (x < -INT_MAX)
-                       x = 0;
+                       x = -INT_MAX;
                *pi = x;
        }
        return 1;