]> granicus.if.org Git - python/commitdiff
Issue #9797: pystate.c wrongly assumed that zero couldn't be a valid
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 8 Sep 2010 12:37:10 +0000 (12:37 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 8 Sep 2010 12:37:10 +0000 (12:37 +0000)
thread-local storage key.

Misc/NEWS
Python/pystate.c

index 7a00e14c4c3c309d5d0d89f6072842e0de8c9dda..894983aef346207e7eea27affe38b74d396d712a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.2 Alpha 3?
 Core and Builtins
 -----------------
 
+- Issue #9797: pystate.c wrongly assumed that zero couldn't be a valid
+  thread-local storage key.
+
 Library
 -------
 
index f113839ef0645fb2aa2f493704ecaae42e446c39..77534fc12f86e6c1660a7d3c09fb87b92d344458 100644 (file)
@@ -340,7 +340,7 @@ PyThreadState_Delete(PyThreadState *tstate)
         Py_FatalError("PyThreadState_Delete: tstate is still current");
     tstate_delete_common(tstate);
 #ifdef WITH_THREAD
-    if (autoTLSkey && PyThread_get_key_value(autoTLSkey) == tstate)
+    if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate)
         PyThread_delete_key_value(autoTLSkey);
 #endif /* WITH_THREAD */
 }
@@ -357,7 +357,7 @@ PyThreadState_DeleteCurrent()
             "PyThreadState_DeleteCurrent: no current tstate");
     _Py_atomic_store_relaxed(&_PyThreadState_Current, NULL);
     tstate_delete_common(tstate);
-    if (autoTLSkey && PyThread_get_key_value(autoTLSkey) == tstate)
+    if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate)
         PyThread_delete_key_value(autoTLSkey);
     PyEval_ReleaseLock();
 }
@@ -580,7 +580,6 @@ void
 _PyGILState_Fini(void)
 {
     PyThread_delete_key(autoTLSkey);
-    autoTLSkey = 0;
     autoInterpreterState = NULL;
 }
 
@@ -592,10 +591,10 @@ _PyGILState_Fini(void)
 static void
 _PyGILState_NoteThreadState(PyThreadState* tstate)
 {
-    /* If autoTLSkey is 0, this must be the very first threadstate created
-       in Py_Initialize().  Don't do anything for now (we'll be back here
-       when _PyGILState_Init is called). */
-    if (!autoTLSkey)
+    /* If autoTLSkey isn't initialized, this must be the very first
+       threadstate created in Py_Initialize().  Don't do anything for now
+       (we'll be back here when _PyGILState_Init is called). */
+    if (!autoInterpreterState)
         return;
 
     /* Stick the thread state for this thread in thread local storage.
@@ -623,7 +622,7 @@ _PyGILState_NoteThreadState(PyThreadState* tstate)
 PyThreadState *
 PyGILState_GetThisThreadState(void)
 {
-    if (autoInterpreterState == NULL || autoTLSkey == 0)
+    if (autoInterpreterState == NULL)
         return NULL;
     return (PyThreadState *)PyThread_get_key_value(autoTLSkey);
 }