Patch 1413181, by Gabriel Becedillas.

PyThreadState_Delete():  if the auto-GIL-state machinery knows about
the thread state, forget it (since the thread state is being deleted,
continuing to remember it can't help, but can hurt if another thread
happens to get created with the same thread id).

I'll backport to 2.4 next.
diff --git a/Misc/NEWS b/Misc/NEWS
index 4f7f8d8..2791cbe 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -230,6 +230,12 @@
   unicode instance if the argument is not an instance of basestring and
   calling __str__ on the argument returns a unicode instance.
 
+- Patch #1413181:  changed ``PyThreadState_Delete()`` to forget about the
+  current thread state when the auto-GIL-state machinery knows about
+  it (since the thread state is being deleted, continuing to remember it
+  can't help, but can hurt if another thread happens to get created with
+  the same thread id).
+
 Extension Modules
 -----------------