summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-03-08 00:52:52 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-03-08 00:52:52 (GMT)
commit9a6338651eb2f474661602a81ee42958fd42d5d4 (patch)
tree0302b7c425f55e6be15d823ec0b9c742e5198fb3 /Objects
parent657e9ebef513ed4049a092f6b155d95c4a773a69 (diff)
parent52c424343d625d3e795bd670aaaf542dfa63b7c7 (diff)
downloadcpython-9a6338651eb2f474661602a81ee42958fd42d5d4.zip
cpython-9a6338651eb2f474661602a81ee42958fd42d5d4.tar.gz
cpython-9a6338651eb2f474661602a81ee42958fd42d5d4.tar.bz2
merge 3.2 (#3787e896dbe9)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 50b9723..dae7ff8 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -862,8 +862,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);