]> granicus.if.org Git - python/commitdiff
Patch 1413181, by Gabriel Becedillas.
authorTim Peters <tim.peters@gmail.com>
Mon, 27 Feb 2006 17:15:31 +0000 (17:15 +0000)
committerTim Peters <tim.peters@gmail.com>
Mon, 27 Feb 2006 17:15:31 +0000 (17:15 +0000)
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.

Misc/NEWS
Python/pystate.c

index 4f7f8d8d71de3a8281116eeeed46b0eb4105f243..2791cbe898551fdfa849a24a596212df66d6fc3c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -230,6 +230,12 @@ Core and builtins
   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
 -----------------
 
index 6584cda775a8b0a6be27cad4c3af0c3d0da1325d..867334e81e032de60023788292aeb7339138f4be 100644 (file)
@@ -262,6 +262,10 @@ PyThreadState_Delete(PyThreadState *tstate)
        if (tstate == _PyThreadState_Current)
                Py_FatalError("PyThreadState_Delete: tstate is still current");
        tstate_delete_common(tstate);
+#ifdef WITH_THREAD
+       if (autoTLSkey && PyThread_get_key_value(autoTLSkey) == tstate)
+               PyThread_delete_key_value(autoTLSkey);
+#endif /* WITH_THREAD */
 }