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
a9f60929
Kaydet (Commit)
a9f60929
authored
Eki 17, 2004
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix and test weak referencing of itertools.tee objects.
üst
837dd93e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
test_itertools.py
Lib/test/test_itertools.py
+8
-0
itertoolsmodule.c
Modules/itertoolsmodule.c
+6
-1
No files found.
Lib/test/test_itertools.py
Dosyayı görüntüle @
a9f60929
import
unittest
from
test
import
test_support
from
itertools
import
*
from
weakref
import
proxy
import
sys
import
operator
import
random
...
...
@@ -382,6 +383,13 @@ class TestBasicOps(unittest.TestCase):
t3
=
tnew
(
t1
)
self
.
assert_
(
list
(
t1
)
==
list
(
t2
)
==
list
(
t3
)
==
list
(
'abc'
))
# test that tee objects are weak referencable
a
,
b
=
tee
(
xrange
(
10
))
p
=
proxy
(
a
)
self
.
assertEqual
(
getattr
(
p
,
'__class__'
),
type
(
b
))
del
a
self
.
assertRaises
(
ReferenceError
,
getattr
,
p
,
'__class__'
)
def
test_StopIteration
(
self
):
self
.
assertRaises
(
StopIteration
,
izip
()
.
next
)
...
...
Modules/itertoolsmodule.c
Dosyayı görüntüle @
a9f60929
...
...
@@ -329,6 +329,7 @@ typedef struct {
PyObject_HEAD
teedataobject
*
dataobj
;
int
index
;
PyObject
*
weakreflist
;
}
teeobject
;
static
PyTypeObject
teedataobject_type
;
...
...
@@ -452,6 +453,7 @@ tee_copy(teeobject *to)
Py_INCREF
(
to
->
dataobj
);
newto
->
dataobj
=
to
->
dataobj
;
newto
->
index
=
to
->
index
;
newto
->
weakreflist
=
NULL
;
return
(
PyObject
*
)
newto
;
}
...
...
@@ -476,6 +478,7 @@ tee_fromiterable(PyObject *iterable)
goto
done
;
to
->
dataobj
=
(
teedataobject
*
)
teedataobject_new
(
it
);
to
->
index
=
0
;
to
->
weakreflist
=
NULL
;
done:
Py_XDECREF
(
it
);
return
(
PyObject
*
)
to
;
...
...
@@ -494,6 +497,8 @@ tee_new(PyTypeObject *type, PyObject *args, PyObject *kw)
static
void
tee_dealloc
(
teeobject
*
to
)
{
if
(
to
->
weakreflist
!=
NULL
)
PyObject_ClearWeakRefs
((
PyObject
*
)
to
);
Py_XDECREF
(
to
->
dataobj
);
PyObject_Del
(
to
);
}
...
...
@@ -533,7 +538,7 @@ static PyTypeObject tee_type = {
0
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
offsetof
(
teeobject
,
weakreflist
),
/* tp_weaklistoffset */
PyObject_SelfIter
,
/* tp_iter */
(
iternextfunc
)
tee_next
,
/* tp_iternext */
tee_methods
,
/* tp_methods */
...
...
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