]> granicus.if.org Git - python/commitdiff
Merged revisions 84623 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 8 Sep 2010 12:40:49 +0000 (12:40 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 8 Sep 2010 12:40:49 +0000 (12:40 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84623 | antoine.pitrou | 2010-09-08 14:37:10 +0200 (mer., 08 sept. 2010) | 4 lines

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

Misc/NEWS
Python/pystate.c

index 9d7ec181468a363804bd1ffcf4dcda3a3021d99d..ea3d0cc524349fdd902ee187b2e7662321932889 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.7.1?
 Core and Builtins
 -----------------
 
+- Issue #9797: pystate.c wrongly assumed that zero couldn't be a valid
+  thread-local storage key.
+
 - Issue #4947: The write() method of sys.stdout and sys.stderr uses their
   encoding and errors attributes instead of using utf-8 in strict mode, to get
   the same behaviour than the print statement.
index 5afc01a72232ca0d147925360dd356ee6ffe613d..c0127be8bf81287d35660eaa6b38e6fe99477cd4 100644 (file)
@@ -298,7 +298,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 */
 }
@@ -314,7 +314,7 @@ PyThreadState_DeleteCurrent()
             "PyThreadState_DeleteCurrent: no current tstate");
     _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();
 }
@@ -534,7 +534,6 @@ void
 _PyGILState_Fini(void)
 {
     PyThread_delete_key(autoTLSkey);
-    autoTLSkey = 0;
     autoInterpreterState = NULL;
 }
 
@@ -546,10 +545,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.
@@ -577,7 +576,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);
 }