Kaydet (Commit) 5b4b2da5 authored tarafından Antoine Pitrou's avatar Antoine Pitrou

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
noticing.
üst d8fdbad8
...@@ -9,6 +9,10 @@ What's New in Python 2.7.3? ...@@ -9,6 +9,10 @@ What's New in Python 2.7.3?
Core and Builtins 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
noticing.
- Issue #13546: Fixed an overflow issue that could crash the intepreter when - Issue #13546: Fixed an overflow issue that could crash the intepreter when
calling sys.setrecursionlimit((1<<31)-1). calling sys.setrecursionlimit((1<<31)-1).
......
...@@ -1013,8 +1013,6 @@ subtype_dealloc(PyObject *self) ...@@ -1013,8 +1013,6 @@ subtype_dealloc(PyObject *self)
assert(basedealloc); assert(basedealloc);
basedealloc(self); basedealloc(self);
PyType_Modified(type);
/* Can't reference self beyond this point */ /* Can't reference self beyond this point */
Py_DECREF(type); Py_DECREF(type);
...@@ -2707,15 +2705,16 @@ type_clear(PyTypeObject *type) ...@@ -2707,15 +2705,16 @@ type_clear(PyTypeObject *type)
for heaptypes. */ for heaptypes. */
assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE);
/* The only field we need to clear is tp_mro, which is part of a /* We need to invalidate the method cache carefully before clearing
hard cycle (its first element is the class itself) that won't the dict, so that other objects caught in a reference cycle
be broken otherwise (it's a tuple and tuples don't have a 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 tp_clear handler). None of the other fields need to be
cleared, and here's why: cleared, and here's why:
tp_dict:
It is a dict, so the collector will call its tp_clear.
tp_cache: tp_cache:
Not used; if it were, it would be a dict. Not used; if it were, it would be a dict.
...@@ -2732,6 +2731,9 @@ type_clear(PyTypeObject *type) ...@@ -2732,6 +2731,9 @@ type_clear(PyTypeObject *type)
A tuple of strings can't be part of a cycle. A tuple of strings can't be part of a cycle.
*/ */
PyType_Modified(type);
if (type->tp_dict)
PyDict_Clear(type->tp_dict);
Py_CLEAR(type->tp_mro); Py_CLEAR(type->tp_mro);
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment