summaryrefslogtreecommitdiffstats
path: root/Python/pystate.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-09-08 12:37:10 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-09-08 12:37:10 (GMT)
commit079ce54efeaed08af1ee979e5f794754337e9c1b (patch)
tree96682a5440b3b8d419fff558c22d81715cd9bf7f /Python/pystate.c
parent121a1c4e11fb2c6f11ec9c01aec2db91d86a0d40 (diff)
downloadcpython-079ce54efeaed08af1ee979e5f794754337e9c1b.zip
cpython-079ce54efeaed08af1ee979e5f794754337e9c1b.tar.gz
cpython-079ce54efeaed08af1ee979e5f794754337e9c1b.tar.bz2
Issue #9797: pystate.c wrongly assumed that zero couldn't be a valid
thread-local storage key.
Diffstat (limited to 'Python/pystate.c')
-rw-r--r--Python/pystate.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index f113839..77534fc 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -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);
}