Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cbd6fb9

Browse files
author
Michael W. Hudson
committed
Handle really big steps in extended slices.
Fixes a test failure on 64 bit platforms (I hope).
1 parent 9050a51 commit cbd6fb9

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

Objects/sliceobject.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,8 @@ PySlice_GetIndicesEx(PySliceObject *r, int length,
121121
*step = 1;
122122
}
123123
else {
124-
*step = PyInt_AsLong(r->step);
125-
if (*step == -1 && PyErr_Occurred()) {
126-
return -1;
127-
}
128-
else if (*step == 0) {
124+
if (!_PyEval_SliceIndex(r->step, step)) return -1;
125+
if (*step == 0) {
129126
PyErr_SetString(PyExc_ValueError,
130127
"slice step cannot be zero");
131128
return -1;

Python/ceval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3507,7 +3507,7 @@ _PyEval_SliceIndex(PyObject *v, int *pi)
35073507
if (x > INT_MAX)
35083508
x = INT_MAX;
35093509
else if (x < -INT_MAX)
3510-
x = 0;
3510+
x = -INT_MAX;
35113511
*pi = x;
35123512
}
35133513
return 1;

0 commit comments

Comments
 (0)