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
a1ca94a1
Kaydet (Commit)
a1ca94a1
authored
Mar 06, 2008
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 2246: itertools grouper object did not participate in GC (should be backported).
üst
ad47fa14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
test_itertools.py
Lib/test/test_itertools.py
+7
-0
itertoolsmodule.c
Modules/itertoolsmodule.c
+15
-5
No files found.
Lib/test/test_itertools.py
Dosyayı görüntüle @
a1ca94a1
...
...
@@ -766,6 +766,13 @@ class TestGC(unittest.TestCase):
a
=
[]
self
.
makecycle
(
groupby
([
a
]
*
2
,
lambda
x
:
x
),
a
)
def
test_issue2246
(
self
):
# Issue 2246 -- the _grouper iterator was not included in GC
n
=
10
keyfunc
=
lambda
x
:
x
for
i
,
j
in
groupby
(
xrange
(
n
),
key
=
keyfunc
):
keyfunc
.
__dict__
.
setdefault
(
'x'
,[])
.
append
(
j
)
def
test_ifilter
(
self
):
a
=
[]
self
.
makecycle
(
ifilter
(
lambda
x
:
True
,
[
a
]
*
2
),
a
)
...
...
Modules/itertoolsmodule.c
Dosyayı görüntüle @
a1ca94a1
...
...
@@ -198,7 +198,7 @@ _grouper_create(groupbyobject *parent, PyObject *tgtkey)
{
_grouperobject
*
igo
;
igo
=
PyObject_New
(
_grouperobject
,
&
_grouper_type
);
igo
=
PyObject_
GC_
New
(
_grouperobject
,
&
_grouper_type
);
if
(
igo
==
NULL
)
return
NULL
;
igo
->
parent
=
(
PyObject
*
)
parent
;
...
...
@@ -206,15 +206,25 @@ _grouper_create(groupbyobject *parent, PyObject *tgtkey)
igo
->
tgtkey
=
tgtkey
;
Py_INCREF
(
tgtkey
);
PyObject_GC_Track
(
igo
);
return
(
PyObject
*
)
igo
;
}
static
void
_grouper_dealloc
(
_grouperobject
*
igo
)
{
PyObject_GC_UnTrack
(
igo
);
Py_DECREF
(
igo
->
parent
);
Py_DECREF
(
igo
->
tgtkey
);
PyObject_Del
(
igo
);
PyObject_GC_Del
(
igo
);
}
static
int
_grouper_traverse
(
_grouperobject
*
igo
,
visitproc
visit
,
void
*
arg
)
{
Py_VISIT
(
igo
->
parent
);
Py_VISIT
(
igo
->
tgtkey
);
return
0
;
}
static
PyObject
*
...
...
@@ -280,9 +290,9 @@ static PyTypeObject _grouper_type = {
PyObject_GenericGetAttr
,
/* tp_getattro */
0
,
/* tp_setattro */
0
,
/* tp_as_buffer */
Py_TPFLAGS_DEFAULT
,
/* tp_flags */
Py_TPFLAGS_DEFAULT
|
Py_TPFLAGS_HAVE_GC
,
/* tp_flags */
0
,
/* tp_doc */
0
,
/* tp_traverse */
(
traverseproc
)
_grouper_traverse
,
/* tp_traverse */
0
,
/* tp_clear */
0
,
/* tp_richcompare */
0
,
/* tp_weaklistoffset */
...
...
@@ -299,7 +309,7 @@ static PyTypeObject _grouper_type = {
0
,
/* tp_init */
0
,
/* tp_alloc */
0
,
/* tp_new */
PyObject_
Del
,
/* tp_free */
PyObject_
GC_Del
,
/* tp_free */
};
...
...
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