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
e46fb861
Kaydet (Commit)
e46fb861
authored
Mar 20, 2017
tarafından
4kir4
Kaydeden (comit)
Serhiy Storchaka
Mar 20, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-28876: bool of large range raises OverflowError (#699)
üst
64508780
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
5 deletions
+27
-5
test_range.py
Lib/test/test_range.py
+13
-4
NEWS
Misc/NEWS
+3
-0
rangeobject.c
Objects/rangeobject.c
+11
-1
No files found.
Lib/test/test_range.py
Dosyayı görüntüle @
e46fb861
...
@@ -98,20 +98,24 @@ class RangeTest(unittest.TestCase):
...
@@ -98,20 +98,24 @@ class RangeTest(unittest.TestCase):
x
=
range
(
10
**
20
+
10
,
10
**
20
,
3
)
x
=
range
(
10
**
20
+
10
,
10
**
20
,
3
)
self
.
assertEqual
(
len
(
x
),
0
)
self
.
assertEqual
(
len
(
x
),
0
)
self
.
assertEqual
(
len
(
list
(
x
)),
0
)
self
.
assertEqual
(
len
(
list
(
x
)),
0
)
self
.
assertFalse
(
x
)
x
=
range
(
10
**
20
,
10
**
20
+
10
,
-
3
)
x
=
range
(
10
**
20
,
10
**
20
+
10
,
-
3
)
self
.
assertEqual
(
len
(
x
),
0
)
self
.
assertEqual
(
len
(
x
),
0
)
self
.
assertEqual
(
len
(
list
(
x
)),
0
)
self
.
assertEqual
(
len
(
list
(
x
)),
0
)
self
.
assertFalse
(
x
)
x
=
range
(
10
**
20
+
10
,
10
**
20
,
-
3
)
x
=
range
(
10
**
20
+
10
,
10
**
20
,
-
3
)
self
.
assertEqual
(
len
(
x
),
4
)
self
.
assertEqual
(
len
(
x
),
4
)
self
.
assertEqual
(
len
(
list
(
x
)),
4
)
self
.
assertEqual
(
len
(
list
(
x
)),
4
)
self
.
assertTrue
(
x
)
# Now test range() with longs
# Now test range() with longs
self
.
assertEqual
(
list
(
range
(
-
2
**
100
)),
[])
for
x
in
[
range
(
-
2
**
100
),
self
.
assertEqual
(
list
(
range
(
0
,
-
2
**
100
)),
[])
range
(
0
,
-
2
**
100
),
self
.
assertEqual
(
list
(
range
(
0
,
2
**
100
,
-
1
)),
[])
range
(
0
,
2
**
100
,
-
1
)]:
self
.
assertEqual
(
list
(
range
(
0
,
2
**
100
,
-
1
)),
[])
self
.
assertEqual
(
list
(
x
),
[])
self
.
assertFalse
(
x
)
a
=
int
(
10
*
sys
.
maxsize
)
a
=
int
(
10
*
sys
.
maxsize
)
b
=
int
(
100
*
sys
.
maxsize
)
b
=
int
(
100
*
sys
.
maxsize
)
...
@@ -152,6 +156,7 @@ class RangeTest(unittest.TestCase):
...
@@ -152,6 +156,7 @@ class RangeTest(unittest.TestCase):
step
=
x
[
1
]
-
x
[
0
]
step
=
x
[
1
]
-
x
[
0
]
length
=
1
+
((
x
[
-
1
]
-
x
[
0
])
//
step
)
length
=
1
+
((
x
[
-
1
]
-
x
[
0
])
//
step
)
return
length
return
length
a
=
-
sys
.
maxsize
a
=
-
sys
.
maxsize
b
=
sys
.
maxsize
b
=
sys
.
maxsize
expected_len
=
b
-
a
expected_len
=
b
-
a
...
@@ -159,6 +164,7 @@ class RangeTest(unittest.TestCase):
...
@@ -159,6 +164,7 @@ class RangeTest(unittest.TestCase):
self
.
assertIn
(
a
,
x
)
self
.
assertIn
(
a
,
x
)
self
.
assertNotIn
(
b
,
x
)
self
.
assertNotIn
(
b
,
x
)
self
.
assertRaises
(
OverflowError
,
len
,
x
)
self
.
assertRaises
(
OverflowError
,
len
,
x
)
self
.
assertTrue
(
x
)
self
.
assertEqual
(
_range_len
(
x
),
expected_len
)
self
.
assertEqual
(
_range_len
(
x
),
expected_len
)
self
.
assertEqual
(
x
[
0
],
a
)
self
.
assertEqual
(
x
[
0
],
a
)
idx
=
sys
.
maxsize
+
1
idx
=
sys
.
maxsize
+
1
...
@@ -176,6 +182,7 @@ class RangeTest(unittest.TestCase):
...
@@ -176,6 +182,7 @@ class RangeTest(unittest.TestCase):
self
.
assertIn
(
a
,
x
)
self
.
assertIn
(
a
,
x
)
self
.
assertNotIn
(
b
,
x
)
self
.
assertNotIn
(
b
,
x
)
self
.
assertRaises
(
OverflowError
,
len
,
x
)
self
.
assertRaises
(
OverflowError
,
len
,
x
)
self
.
assertTrue
(
x
)
self
.
assertEqual
(
_range_len
(
x
),
expected_len
)
self
.
assertEqual
(
_range_len
(
x
),
expected_len
)
self
.
assertEqual
(
x
[
0
],
a
)
self
.
assertEqual
(
x
[
0
],
a
)
idx
=
sys
.
maxsize
+
1
idx
=
sys
.
maxsize
+
1
...
@@ -194,6 +201,7 @@ class RangeTest(unittest.TestCase):
...
@@ -194,6 +201,7 @@ class RangeTest(unittest.TestCase):
self
.
assertIn
(
a
,
x
)
self
.
assertIn
(
a
,
x
)
self
.
assertNotIn
(
b
,
x
)
self
.
assertNotIn
(
b
,
x
)
self
.
assertRaises
(
OverflowError
,
len
,
x
)
self
.
assertRaises
(
OverflowError
,
len
,
x
)
self
.
assertTrue
(
x
)
self
.
assertEqual
(
_range_len
(
x
),
expected_len
)
self
.
assertEqual
(
_range_len
(
x
),
expected_len
)
self
.
assertEqual
(
x
[
0
],
a
)
self
.
assertEqual
(
x
[
0
],
a
)
idx
=
sys
.
maxsize
+
1
idx
=
sys
.
maxsize
+
1
...
@@ -212,6 +220,7 @@ class RangeTest(unittest.TestCase):
...
@@ -212,6 +220,7 @@ class RangeTest(unittest.TestCase):
self
.
assertIn
(
a
,
x
)
self
.
assertIn
(
a
,
x
)
self
.
assertNotIn
(
b
,
x
)
self
.
assertNotIn
(
b
,
x
)
self
.
assertRaises
(
OverflowError
,
len
,
x
)
self
.
assertRaises
(
OverflowError
,
len
,
x
)
self
.
assertTrue
(
x
)
self
.
assertEqual
(
_range_len
(
x
),
expected_len
)
self
.
assertEqual
(
_range_len
(
x
),
expected_len
)
self
.
assertEqual
(
x
[
0
],
a
)
self
.
assertEqual
(
x
[
0
],
a
)
idx
=
sys
.
maxsize
+
1
idx
=
sys
.
maxsize
+
1
...
...
Misc/NEWS
Dosyayı görüntüle @
e46fb861
...
@@ -35,6 +35,9 @@ Core and Builtins
...
@@ -35,6 +35,9 @@ Core and Builtins
- bpo-28893: Set correct __cause__ for errors about invalid awaitables
- bpo-28893: Set correct __cause__ for errors about invalid awaitables
returned from __aiter__ and __anext__.
returned from __aiter__ and __anext__.
- bpo-28876: ``bool(range)`` works even if ``len(range)``
raises :exc:`OverflowError`.
- bpo-29683: Fixes to memory allocation in _PyCode_SetExtra. Patch by
- bpo-29683: Fixes to memory allocation in _PyCode_SetExtra. Patch by
Brian Coleman.
Brian Coleman.
...
...
Objects/rangeobject.c
Dosyayı görüntüle @
e46fb861
...
@@ -668,6 +668,16 @@ static PyMappingMethods range_as_mapping = {
...
@@ -668,6 +668,16 @@ static PyMappingMethods range_as_mapping = {
(
objobjargproc
)
0
,
/* mp_ass_subscript */
(
objobjargproc
)
0
,
/* mp_ass_subscript */
};
};
static
int
range_bool
(
rangeobject
*
self
)
{
return
PyObject_IsTrue
(
self
->
length
);
}
static
PyNumberMethods
range_as_number
=
{
.
nb_bool
=
(
inquiry
)
range_bool
,
};
static
PyObject
*
range_iter
(
PyObject
*
seq
);
static
PyObject
*
range_iter
(
PyObject
*
seq
);
static
PyObject
*
range_reverse
(
PyObject
*
seq
);
static
PyObject
*
range_reverse
(
PyObject
*
seq
);
...
@@ -707,7 +717,7 @@ PyTypeObject PyRange_Type = {
...
@@ -707,7 +717,7 @@ PyTypeObject PyRange_Type = {
0
,
/* tp_setattr */
0
,
/* tp_setattr */
0
,
/* tp_reserved */
0
,
/* tp_reserved */
(
reprfunc
)
range_repr
,
/* tp_repr */
(
reprfunc
)
range_repr
,
/* tp_repr */
0
,
/* tp_as_number */
&
range_as_number
,
/* tp_as_number */
&
range_as_sequence
,
/* tp_as_sequence */
&
range_as_sequence
,
/* tp_as_sequence */
&
range_as_mapping
,
/* tp_as_mapping */
&
range_as_mapping
,
/* tp_as_mapping */
(
hashfunc
)
range_hash
,
/* tp_hash */
(
hashfunc
)
range_hash
,
/* tp_hash */
...
...
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