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
52c42434
Kaydet (Commit)
52c42434
authored
Mar 08, 2012
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
allow cycles throught the __dict__ slot to be cleared (closes #1469629)
Patch from Armin, test from me.
üst
1ae230aa
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
4 deletions
+27
-4
test_descr.py
Lib/test/test_descr.py
+17
-2
NEWS
Misc/NEWS
+3
-0
typeobject.c
Objects/typeobject.c
+7
-2
No files found.
Lib/test/test_descr.py
Dosyayı görüntüle @
52c42434
import
builtins
import
gc
import
sys
import
types
import
math
import
unittest
import
weakref
from
copy
import
deepcopy
from
test
import
support
...
...
@@ -1186,7 +1188,6 @@ order (MRO) for bases """
self
.
assertEqual
(
Counted
.
counter
,
0
)
# Test lookup leaks [SF bug 572567]
import
gc
if
hasattr
(
gc
,
'get_objects'
):
class
G
(
object
):
def
__eq__
(
self
,
other
):
...
...
@@ -4380,7 +4381,6 @@ order (MRO) for bases """
self
.
assertRaises
(
AttributeError
,
getattr
,
C
(),
"attr"
)
self
.
assertEqual
(
descr
.
counter
,
4
)
import
gc
class
EvilGetattribute
(
object
):
# This used to segfault
def
__getattr__
(
self
,
name
):
...
...
@@ -4429,6 +4429,21 @@ order (MRO) for bases """
foo
=
Foo
()
str
(
foo
)
def
test_cycle_through_dict
(
self
):
# See bug #1469629
class
X
(
dict
):
def
__init__
(
self
):
dict
.
__init__
(
self
)
self
.
__dict__
=
self
x
=
X
()
x
.
attr
=
42
wr
=
weakref
.
ref
(
x
)
del
x
support
.
gc_collect
()
self
.
assertIsNone
(
wr
())
for
o
in
gc
.
get_objects
():
self
.
assertIsNot
(
type
(
o
),
X
)
class
DictProxyTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
class
C
(
object
):
...
...
Misc/NEWS
Dosyayı görüntüle @
52c42434
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.2.3 release candidate 1?
Core and Builtins
-----------------
- Issue #1469629: Allow cycles through an object's __dict__ slot to be
collected. (For example if ``x.__dict__ is x``).
- Issue #14172: Fix reference leak when marshalling a buffer-like object
(other than a bytes object).
...
...
Objects/typeobject.c
Dosyayı görüntüle @
52c42434
...
...
@@ -830,8 +830,13 @@ subtype_clear(PyObject *self)
assert
(
base
);
}
/* There's no need to clear the instance dict (if any);
the collector will call its tp_clear handler. */
/* Clear the instance dict (if any), to break cycles involving only
__dict__ slots (as in the case 'self.__dict__ is self'). */
if
(
type
->
tp_dictoffset
!=
base
->
tp_dictoffset
)
{
PyObject
**
dictptr
=
_PyObject_GetDictPtr
(
self
);
if
(
dictptr
&&
*
dictptr
)
Py_CLEAR
(
*
dictptr
);
}
if
(
baseclear
)
return
baseclear
(
self
);
...
...
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