[Python-checkins] cpython (merge 3.2 -> default): Fix the fix for issue #12149: it was incorrect, although it had the side
python-checkins at python.org
Thu Dec 15 14:21:40 CET 2011
user: Antoine Pitrou <solipsis at pitrou.net>
date: Thu Dec 15 14:17:36 2011 +0100
Fix the fix for issue #12149: it was incorrect, although it had the side
effect of appearing to resolve the issue. Thanks to Mark Shannon for
Misc/NEWS | 4 ++++
Objects/typeobject.c | 18 ++++++++++--------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
@@ -10,6 +10,10 @@
Core and Builtins
+- Fix the fix for issue #12149: it was incorrect, although it had the side
+ effect of appearing to resolve the issue. Thanks to Mark Shannon for
- Issue #13505: Pickle bytes objects in a way that is compatible with
Python 2 when using protocols <= 2.
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
@@ -999,8 +999,6 @@
/* Can't reference self beyond this point */
@@ -2776,15 +2774,16 @@
for heaptypes. */
assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE);
- /* The only field we need to clear is tp_mro, which is part of a
- hard cycle (its first element is the class itself) that won't
- be broken otherwise (it's a tuple and tuples don't have a
+ /* We need to invalidate the method cache carefully before clearing
+ the dict, so that other objects caught in a reference cycle
+ don't start calling destroyed methods.
+ Otherwise, the only field we need to clear is tp_mro, which is
+ part of a hard cycle (its first element is the class itself) that
+ won't be broken otherwise (it's a tuple and tuples don't have a
tp_clear handler). None of the other fields need to be
cleared, and here's why:
- It is a dict, so the collector will call its tp_clear.
Not used; if it were, it would be a dict.
@@ -2801,6 +2800,9 @@
A tuple of strings can't be part of a cycle.
+ if (type->tp_dict)
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins