From cbd6fb90069ded106833efc42b1c93bcf9b958c3 Mon Sep 17 00:00:00 2001 From: "Michael W. Hudson" Date: Wed, 6 Nov 2002 15:17:32 +0000 Subject: [PATCH] Handle really big steps in extended slices. Fixes a test failure on 64 bit platforms (I hope). --- Objects/sliceobject.c | 7 ++----- Python/ceval.c | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c index a035e5faf0..7198cca4b1 100644 --- a/Objects/sliceobject.c +++ b/Objects/sliceobject.c @@ -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; diff --git a/Python/ceval.c b/Python/ceval.c index afc480e151..09b88a6ca7 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -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; -- 2.49.0