SF 1055820: weakref callback vs gc vs threads

In cyclic gc, clear weakrefs to unreachable objects before allowing any
Python code (weakref callbacks or __del__ methods) to run.

This is a critical bugfix, affecting all versions of Python since weakrefs
were introduced.  I'll backport to 2.3.
This commit is contained in:
Tim Peters 2004-10-30 23:09:22 +00:00
parent d7bcf4deb1
commit ead8b7ab30
6 changed files with 531 additions and 110 deletions

View file

@ -850,7 +850,9 @@ PyWeakref_GetObject(PyObject *ref)
return PyWeakref_GET_OBJECT(ref);
}
/* Note that there's an inlined copy-paste of handle_callback() in gcmodule.c's
* handle_weakrefs().
*/
static void
handle_callback(PyWeakReference *ref, PyObject *callback)
{