Skip to content

Commit 3c6261a

Browse files
committed
Merged revisions 84623 via svnmerge from
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. ........
1 parent b58c3c7 commit 3c6261a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Misc/NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 3.1.3?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #9797: pystate.c wrongly assumed that zero couldn't be a valid
16+
thread-local storage key.
17+
1518
- Issue #9737: Fix a crash when trying to delete a slice or an item from
1619
a memoryview object.
1720

Python/pystate.c

+7-8
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ PyThreadState_Delete(PyThreadState *tstate)
338338
Py_FatalError("PyThreadState_Delete: tstate is still current");
339339
tstate_delete_common(tstate);
340340
#ifdef WITH_THREAD
341-
if (autoTLSkey && PyThread_get_key_value(autoTLSkey) == tstate)
341+
if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate)
342342
PyThread_delete_key_value(autoTLSkey);
343343
#endif /* WITH_THREAD */
344344
}
@@ -354,7 +354,7 @@ PyThreadState_DeleteCurrent()
354354
"PyThreadState_DeleteCurrent: no current tstate");
355355
_PyThreadState_Current = NULL;
356356
tstate_delete_common(tstate);
357-
if (autoTLSkey && PyThread_get_key_value(autoTLSkey) == tstate)
357+
if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate)
358358
PyThread_delete_key_value(autoTLSkey);
359359
PyEval_ReleaseLock();
360360
}
@@ -574,7 +574,6 @@ void
574574
_PyGILState_Fini(void)
575575
{
576576
PyThread_delete_key(autoTLSkey);
577-
autoTLSkey = 0;
578577
autoInterpreterState = NULL;
579578
}
580579

@@ -586,10 +585,10 @@ _PyGILState_Fini(void)
586585
static void
587586
_PyGILState_NoteThreadState(PyThreadState* tstate)
588587
{
589-
/* If autoTLSkey is 0, this must be the very first threadstate created
590-
in Py_Initialize(). Don't do anything for now (we'll be back here
591-
when _PyGILState_Init is called). */
592-
if (!autoTLSkey)
588+
/* If autoTLSkey isn't initialized, this must be the very first
589+
threadstate created in Py_Initialize(). Don't do anything for now
590+
(we'll be back here when _PyGILState_Init is called). */
591+
if (!autoInterpreterState)
593592
return;
594593

595594
/* Stick the thread state for this thread in thread local storage.
@@ -617,7 +616,7 @@ _PyGILState_NoteThreadState(PyThreadState* tstate)
617616
PyThreadState *
618617
PyGILState_GetThisThreadState(void)
619618
{
620-
if (autoInterpreterState == NULL || autoTLSkey == 0)
619+
if (autoInterpreterState == NULL)
621620
return NULL;
622621
return (PyThreadState *)PyThread_get_key_value(autoTLSkey);
623622
}

0 commit comments

Comments
 (0)