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
5cab2e3a
Kaydet (Commit)
5cab2e3a
authored
Şub 10, 2004
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Give itertools.repeat() a length method.
üst
27da291b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
test_itertools.py
Lib/test/test_itertools.py
+7
-1
itertoolsmodule.c
Modules/itertoolsmodule.c
+14
-1
No files found.
Lib/test/test_itertools.py
Dosyayı görüntüle @
5cab2e3a
...
@@ -607,6 +607,12 @@ class TestVariousIteratorArgs(unittest.TestCase):
...
@@ -607,6 +607,12 @@ class TestVariousIteratorArgs(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
list
,
tee
(
N
(
s
))[
0
])
self
.
assertRaises
(
TypeError
,
list
,
tee
(
N
(
s
))[
0
])
self
.
assertRaises
(
ZeroDivisionError
,
list
,
tee
(
E
(
s
))[
0
])
self
.
assertRaises
(
ZeroDivisionError
,
list
,
tee
(
E
(
s
))[
0
])
class
LengthTransparency
(
unittest
.
TestCase
):
def
test_repeat
(
self
):
self
.
assertEqual
(
len
(
repeat
(
None
,
50
)),
50
)
self
.
assertRaises
(
TypeError
,
len
,
repeat
(
None
))
class
RegressionTests
(
unittest
.
TestCase
):
class
RegressionTests
(
unittest
.
TestCase
):
def
test_sf_793826
(
self
):
def
test_sf_793826
(
self
):
...
@@ -826,7 +832,7 @@ __test__ = {'libreftest' : libreftest}
...
@@ -826,7 +832,7 @@ __test__ = {'libreftest' : libreftest}
def
test_main
(
verbose
=
None
):
def
test_main
(
verbose
=
None
):
test_classes
=
(
TestBasicOps
,
TestVariousIteratorArgs
,
TestGC
,
test_classes
=
(
TestBasicOps
,
TestVariousIteratorArgs
,
TestGC
,
RegressionTests
)
RegressionTests
,
LengthTransparency
)
test_support
.
run_unittest
(
*
test_classes
)
test_support
.
run_unittest
(
*
test_classes
)
# verify reference counting
# verify reference counting
...
...
Modules/itertoolsmodule.c
Dosyayı görüntüle @
5cab2e3a
...
@@ -2347,6 +2347,19 @@ repeat_next(repeatobject *ro)
...
@@ -2347,6 +2347,19 @@ repeat_next(repeatobject *ro)
return
ro
->
element
;
return
ro
->
element
;
}
}
static
int
repeat_len
(
repeatobject
*
ro
)
{
if
(
ro
->
cnt
==
-
1
)
PyErr_SetString
(
PyExc_TypeError
,
"len() of unsized object"
);
return
(
int
)(
ro
->
cnt
);
}
static
PySequenceMethods
repeat_as_sequence
=
{
(
inquiry
)
repeat_len
,
/* sq_length */
0
,
/* sq_concat */
};
PyDoc_STRVAR
(
repeat_doc
,
PyDoc_STRVAR
(
repeat_doc
,
"repeat(element [,times]) -> create an iterator which returns the element
\n
\
"repeat(element [,times]) -> create an iterator which returns the element
\n
\
for the specified number of times. If not specified, returns the element
\n
\
for the specified number of times. If not specified, returns the element
\n
\
...
@@ -2366,7 +2379,7 @@ static PyTypeObject repeat_type = {
...
@@ -2366,7 +2379,7 @@ static PyTypeObject repeat_type = {
0
,
/* tp_compare */
0
,
/* tp_compare */
0
,
/* tp_repr */
0
,
/* tp_repr */
0
,
/* tp_as_number */
0
,
/* tp_as_number */
0
,
/* tp_as_sequence */
&
repeat_as_sequence
,
/* tp_as_sequence */
0
,
/* tp_as_mapping */
0
,
/* tp_as_mapping */
0
,
/* tp_hash */
0
,
/* tp_hash */
0
,
/* tp_call */
0
,
/* tp_call */
...
...
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