mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
Issue #13496: Merge from 3.2
This commit is contained in:
commit
da4210f77d
3 changed files with 18 additions and 2 deletions
|
|
@ -21,7 +21,10 @@ internal_bisect_right(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t
|
|||
return -1;
|
||||
}
|
||||
while (lo < hi) {
|
||||
mid = (lo + hi) / 2;
|
||||
/* The (size_t)cast ensures that the addition and subsequent division
|
||||
are performed as unsigned operations, avoiding difficulties from
|
||||
signed overflow. (See issue 13496.) */
|
||||
mid = ((size_t)lo + hi) / 2;
|
||||
litem = PySequence_GetItem(list, mid);
|
||||
if (litem == NULL)
|
||||
return -1;
|
||||
|
|
@ -123,7 +126,10 @@ internal_bisect_left(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t h
|
|||
return -1;
|
||||
}
|
||||
while (lo < hi) {
|
||||
mid = (lo + hi) / 2;
|
||||
/* The (size_t)cast ensures that the addition and subsequent division
|
||||
are performed as unsigned operations, avoiding difficulties from
|
||||
signed overflow. (See issue 13496.) */
|
||||
mid = ((size_t)lo + hi) / 2;
|
||||
litem = PySequence_GetItem(list, mid);
|
||||
if (litem == NULL)
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue