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
3cd1e42d
Kaydet (Commit)
3cd1e42d
authored
Tem 10, 2008
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 3301: Bisect functions behaved badly when lo was negative.
üst
d2cd86dd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
0 deletions
+27
-0
bisect.py
Lib/bisect.py
+8
-0
test_bisect.py
Lib/test/test_bisect.py
+8
-0
NEWS
Misc/NEWS
+3
-0
_bisectmodule.c
Modules/_bisectmodule.c
+8
-0
No files found.
Lib/bisect.py
Dosyayı görüntüle @
3cd1e42d
...
...
@@ -9,6 +9,8 @@ def insort_right(a, x, lo=0, hi=None):
slice of a to be searched.
"""
if
lo
<
0
:
raise
ValueError
(
'lo must be non-negative'
)
if
hi
is
None
:
hi
=
len
(
a
)
while
lo
<
hi
:
...
...
@@ -30,6 +32,8 @@ def bisect_right(a, x, lo=0, hi=None):
slice of a to be searched.
"""
if
lo
<
0
:
raise
ValueError
(
'lo must be non-negative'
)
if
hi
is
None
:
hi
=
len
(
a
)
while
lo
<
hi
:
...
...
@@ -49,6 +53,8 @@ def insort_left(a, x, lo=0, hi=None):
slice of a to be searched.
"""
if
lo
<
0
:
raise
ValueError
(
'lo must be non-negative'
)
if
hi
is
None
:
hi
=
len
(
a
)
while
lo
<
hi
:
...
...
@@ -69,6 +75,8 @@ def bisect_left(a, x, lo=0, hi=None):
slice of a to be searched.
"""
if
lo
<
0
:
raise
ValueError
(
'lo must be non-negative'
)
if
hi
is
None
:
hi
=
len
(
a
)
while
lo
<
hi
:
...
...
Lib/test/test_bisect.py
Dosyayı görüntüle @
3cd1e42d
...
...
@@ -114,6 +114,14 @@ class TestBisect(unittest.TestCase):
self
.
assertEqual
(
func
(
data
,
elem
),
expected
)
self
.
assertEqual
(
func
(
UserList
(
data
),
elem
),
expected
)
def
test_negative_lo
(
self
):
# Issue 3301
mod
=
self
.
module
self
.
assertRaises
(
ValueError
,
mod
.
bisect_left
,
[
1
,
2
,
3
],
5
,
-
1
,
3
),
self
.
assertRaises
(
ValueError
,
mod
.
bisect_right
,
[
1
,
2
,
3
],
5
,
-
1
,
3
),
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_random
(
self
,
n
=
25
):
from
random
import
randrange
for
i
in
xrange
(
n
):
...
...
Misc/NEWS
Dosyayı görüntüle @
3cd1e42d
...
...
@@ -10,6 +10,7 @@ What's New in Python 2.6 beta 2?
Core and Builtins
-----------------
- Issue #2517: Allow unicode messages in Exceptions again by correctly
bypassing the instance dictionary when looking up __unicode__ on
new-style classes.
...
...
@@ -40,6 +41,8 @@ Core and Builtins
Library
-------
- Issue #3301: Bisect module modules behaved badly when lo was negative.
- Issue #839496: SimpleHTTPServer used to open text files in text mode. This is
both unnecessary (HTTP allows text content to be sent in several forms) and
wrong because the actual transmitted size could differ with the
...
...
Modules/_bisectmodule.c
Dosyayı görüntüle @
3cd1e42d
...
...
@@ -11,6 +11,10 @@ internal_bisect_right(PyObject *list, PyObject *item, Py_ssize_t lo, Py_ssize_t
PyObject
*
litem
;
Py_ssize_t
mid
,
res
;
if
(
lo
<
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"lo must be non-negative"
);
return
-
1
;
}
if
(
hi
==
-
1
)
{
hi
=
PySequence_Size
(
list
);
if
(
hi
<
0
)
...
...
@@ -108,6 +112,10 @@ internal_bisect_left(PyObject *list, PyObject *item, int lo, int hi)
PyObject
*
litem
;
int
mid
,
res
;
if
(
lo
<
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"lo must be non-negative"
);
return
-
1
;
}
if
(
hi
==
-
1
)
{
hi
=
PySequence_Size
(
list
);
if
(
hi
<
0
)
...
...
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