Index: Modules/threadmodule.c =================================================================== --- Modules/threadmodule.c (revision 66050) +++ Modules/threadmodule.c (working copy) @@ -278,7 +278,9 @@ return NULL; } - Py_CLEAR(self->dict); + while (self->dict != NULL) { + Py_CLEAR(self->dict); + } Py_INCREF(ldict); self->dict = ldict; /* still borrowed */ @@ -297,7 +299,9 @@ /* The call to tp_init above may have caused another thread to run. Install our ldict again. */ if (self->dict != ldict) { - Py_CLEAR(self->dict); + while (self->dict != NULL) { + Py_CLEAR(self->dict); + } Py_INCREF(ldict); self->dict = ldict; }