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
6d121f16
Kaydet (Commit)
6d121f16
authored
Şub 08, 2007
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Do not let overflows in enumerate() and count() pass silently.
üst
de33c624
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
test_itertools.py
Lib/test/test_itertools.py
+1
-2
itertoolsmodule.c
Modules/itertoolsmodule.c
+5
-0
enumobject.c
Objects/enumobject.c
+6
-0
No files found.
Lib/test/test_itertools.py
Dosyayı görüntüle @
6d121f16
...
@@ -52,8 +52,7 @@ class TestBasicOps(unittest.TestCase):
...
@@ -52,8 +52,7 @@ class TestBasicOps(unittest.TestCase):
self
.
assertEqual
(
take
(
2
,
zip
(
'abc'
,
count
(
3
))),
[(
'a'
,
3
),
(
'b'
,
4
)])
self
.
assertEqual
(
take
(
2
,
zip
(
'abc'
,
count
(
3
))),
[(
'a'
,
3
),
(
'b'
,
4
)])
self
.
assertRaises
(
TypeError
,
count
,
2
,
3
)
self
.
assertRaises
(
TypeError
,
count
,
2
,
3
)
self
.
assertRaises
(
TypeError
,
count
,
'a'
)
self
.
assertRaises
(
TypeError
,
count
,
'a'
)
c
=
count
(
sys
.
maxint
-
2
)
# verify that rollover doesn't crash
self
.
assertRaises
(
OverflowError
,
list
,
islice
(
count
(
sys
.
maxint
-
5
),
10
))
c
.
next
();
c
.
next
();
c
.
next
();
c
.
next
();
c
.
next
()
c
=
count
(
3
)
c
=
count
(
3
)
self
.
assertEqual
(
repr
(
c
),
'count(3)'
)
self
.
assertEqual
(
repr
(
c
),
'count(3)'
)
c
.
next
()
c
.
next
()
...
...
Modules/itertoolsmodule.c
Dosyayı görüntüle @
6d121f16
...
@@ -2073,6 +2073,11 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -2073,6 +2073,11 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static
PyObject
*
static
PyObject
*
count_next
(
countobject
*
lz
)
count_next
(
countobject
*
lz
)
{
{
if
(
lz
->
cnt
==
LONG_MAX
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"cannot count beyond LONG_MAX"
);
return
NULL
;
}
return
PyInt_FromSsize_t
(
lz
->
cnt
++
);
return
PyInt_FromSsize_t
(
lz
->
cnt
++
);
}
}
...
...
Objects/enumobject.c
Dosyayı görüntüle @
6d121f16
...
@@ -62,6 +62,12 @@ enum_next(enumobject *en)
...
@@ -62,6 +62,12 @@ enum_next(enumobject *en)
PyObject
*
result
=
en
->
en_result
;
PyObject
*
result
=
en
->
en_result
;
PyObject
*
it
=
en
->
en_sit
;
PyObject
*
it
=
en
->
en_sit
;
if
(
en
->
en_index
==
LONG_MAX
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"enumerate() is limited to LONG_MAX items"
);
return
NULL
;
}
next_item
=
(
*
it
->
ob_type
->
tp_iternext
)(
it
);
next_item
=
(
*
it
->
ob_type
->
tp_iternext
)(
it
);
if
(
next_item
==
NULL
)
if
(
next_item
==
NULL
)
return
NULL
;
return
NULL
;
...
...
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