Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
0407e960
Kaydet (Commit)
0407e960
authored
Nis 15, 2012
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 13496: Fix bisect.bisect overflow bug for large collections.
üst
9c0baf72
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
2 deletions
+21
-2
test_bisect.py
Lib/test/test_bisect.py
+7
-0
NEWS
Misc/NEWS
+3
-0
_bisectmodule.c
Modules/_bisectmodule.c
+11
-2
No files found.
Lib/test/test_bisect.py
Dosyayı görüntüle @
0407e960
...
...
@@ -122,6 +122,13 @@ class TestBisect(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
mod
.
insort_left
,
[
1
,
2
,
3
],
5
,
-
1
,
3
),
self
.
assertRaises
(
ValueError
,
mod
.
insort_right
,
[
1
,
2
,
3
],
5
,
-
1
,
3
),
def
test_large_range
(
self
):
# Issue 13496
mod
=
self
.
module
data
=
xrange
(
sys
.
maxsize
-
1
)
self
.
assertEqual
(
mod
.
bisect_left
(
data
,
sys
.
maxsize
-
3
),
sys
.
maxsize
-
3
)
self
.
assertEqual
(
mod
.
bisect_right
(
data
,
sys
.
maxsize
-
3
),
sys
.
maxsize
-
2
)
def
test_random
(
self
,
n
=
25
):
from
random
import
randrange
for
i
in
xrange
(
n
):
...
...
Misc/NEWS
Dosyayı görüntüle @
0407e960
...
...
@@ -48,6 +48,9 @@ Core and Builtins
Library
-------
-
Issue
#
13496
:
Fix
potential
overflow
in
bisect
.
bisect
algorithm
when
applied
to
a
collection
of
size
>
sys
.
maxsize
/
2.
-
Issue
#
14399
:
zipfile
now
recognizes
that
the
archive
has
been
modified
even
if
only
the
comment
is
changed
.
As
a
consequence
of
this
fix
,
ZipFile
is
now
a
new
style
class
.
...
...
Modules/_bisectmodule.c
Dosyayı görüntüle @
0407e960
...
...
@@ -21,7 +21,13 @@ 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.) */
printf
(
"lo: %d
\n
"
,
lo
);
printf
(
"hi: %d
\n
"
,
hi
);
printf
(
"mid: %d
\n
"
,
mid
);
mid
=
((
size_t
)
lo
+
hi
)
/
2
;
litem
=
PySequence_GetItem
(
list
,
mid
);
if
(
litem
==
NULL
)
return
-
1
;
...
...
@@ -122,7 +128,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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment