[Python-checkins] r84623 - in python/branches/py3k: Misc/NEWS Python/pystate.c

antoine.pitrou python-checkins at python.org
Wed Sep 8 14:37:10 CEST 2010


Author: antoine.pitrou
Date: Wed Sep  8 14:37:10 2010
New Revision: 84623

Log:
Issue #9797: pystate.c wrongly assumed that zero couldn't be a valid
thread-local storage key.



Modified:
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Python/pystate.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Wed Sep  8 14:37:10 2010
@@ -10,6 +10,9 @@
 Core and Builtins
 -----------------
 
+- Issue #9797: pystate.c wrongly assumed that zero couldn't be a valid
+  thread-local storage key.
+
 Library
 -------
 

Modified: python/branches/py3k/Python/pystate.c
==============================================================================
--- python/branches/py3k/Python/pystate.c	(original)
+++ python/branches/py3k/Python/pystate.c	Wed Sep  8 14:37:10 2010
@@ -340,7 +340,7 @@
         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: 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 @@
 _PyGILState_Fini(void)
 {
     PyThread_delete_key(autoTLSkey);
-    autoTLSkey = 0;
     autoInterpreterState = NULL;
 }
 
@@ -592,10 +591,10 @@
 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 @@
 PyThreadState *
 PyGILState_GetThisThreadState(void)
 {
-    if (autoInterpreterState == NULL || autoTLSkey == 0)
+    if (autoInterpreterState == NULL)
         return NULL;
     return (PyThreadState *)PyThread_get_key_value(autoTLSkey);
 }


More information about the Python-checkins mailing list