#6990: clear threading.local's key only after its thread state is removed:

fixes local subclasses leaving old state around after a ref cycle GC which
could be recycled by new locals
This commit is contained in:
Philip Jenvey 2009-09-29 04:32:44 +00:00
parent b93fff0a57
commit dbf3b258e7
3 changed files with 42 additions and 1 deletions

View file

@ -244,7 +244,6 @@ local_traverse(localobject *self, visitproc visit, void *arg)
static int
local_clear(localobject *self)
{
Py_CLEAR(self->key);
Py_CLEAR(self->args);
Py_CLEAR(self->kw);
Py_CLEAR(self->dict);
@ -266,6 +265,7 @@ local_dealloc(localobject *self)
PyDict_DelItem(tstate->dict, self->key);
}
Py_XDECREF(self->key);
local_clear(self);
Py_TYPE(self)->tp_free((PyObject*)self);
}