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

Skip to content

Commit e46d155

Browse files
author
Michael W. Hudson
committed
In the process of adding all the extended slice support I attempted to
change _PyEval_SliceIndex to round massively negative longs up to -INT_MAX, instead of 0 but botched it. Get it right. Thx to Armin for the report.
1 parent ce56c37 commit e46d155

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Python/ceval.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3614,8 +3614,8 @@ _PyEval_SliceIndex(PyObject *v, int *pi)
36143614

36153615
/* It's an overflow error, so we need to
36163616
check the sign of the long integer,
3617-
set the value to INT_MAX or 0, and clear
3618-
the error. */
3617+
set the value to INT_MAX or -INT_MAX,
3618+
and clear the error. */
36193619

36203620
/* Create a long integer with a value of 0 */
36213621
long_zero = PyLong_FromLong(0L);
@@ -3628,10 +3628,10 @@ _PyEval_SliceIndex(PyObject *v, int *pi)
36283628
Py_DECREF(long_zero);
36293629
if (cmp < 0)
36303630
return 0;
3631-
else if (cmp > 0)
3631+
else if (cmp)
36323632
x = INT_MAX;
36333633
else
3634-
x = 0;
3634+
x = -INT_MAX;
36353635
}
36363636
} else {
36373637
PyErr_SetString(PyExc_TypeError,

0 commit comments

Comments
 (0)