diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-04-17 09:39:28 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-04-17 09:39:28 +0300 |
commit | 67dfb592d054602f43aa6f3239552709ed42a6c8 (patch) | |
tree | e40fb975728a2c7d941b657306aa078a16753adc /Python/pystate.c | |
parent | 9f70a4849d1a62db5ec8e2ba5b06784d69480fe3 (diff) | |
parent | 619fd27374ff0713563a37678f6d8f6ad9fc30f5 (diff) | |
download | cpython-67dfb592d054602f43aa6f3239552709ed42a6c8.tar.gz |
Issue #26778: Fixed "a/an/and" typos in code comment, documentation and error
messages.
Diffstat (limited to 'Python/pystate.c')
-rw-r--r-- | Python/pystate.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/Python/pystate.c b/Python/pystate.c index 6d1c6d0a1f..0503f32670 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -34,6 +34,8 @@ to avoid the expense of doing their own locking). extern "C" { #endif +int _PyGILState_check_enabled = 1; + #ifdef WITH_THREAD #include "pythread.h" static PyThread_type_lock head_mutex = NULL; /* Protects interp->tstate_head */ @@ -45,7 +47,7 @@ static PyThread_type_lock head_mutex = NULL; /* Protects interp->tstate_head */ GILState implementation */ static PyInterpreterState *autoInterpreterState = NULL; -static int autoTLSkey = 0; +static int autoTLSkey = -1; #else #define HEAD_INIT() /* Nothing */ #define HEAD_LOCK() /* Nothing */ @@ -449,10 +451,10 @@ PyThreadState_DeleteCurrent() if (tstate == NULL) Py_FatalError( "PyThreadState_DeleteCurrent: no current tstate"); - SET_TSTATE(NULL); + tstate_delete_common(tstate); if (autoInterpreterState && PyThread_get_key_value(autoTLSkey) == tstate) PyThread_delete_key_value(autoTLSkey); - tstate_delete_common(tstate); + SET_TSTATE(NULL); PyEval_ReleaseLock(); } #endif /* WITH_THREAD */ @@ -696,7 +698,7 @@ PyThreadState_IsCurrent(PyThreadState *tstate) } /* Internal initialization/finalization functions called by - Py_Initialize/Py_Finalize + Py_Initialize/Py_FinalizeEx */ void _PyGILState_Init(PyInterpreterState *i, PyThreadState *t) @@ -712,10 +714,17 @@ _PyGILState_Init(PyInterpreterState *i, PyThreadState *t) _PyGILState_NoteThreadState(t); } +PyInterpreterState * +_PyGILState_GetInterpreterStateUnsafe(void) +{ + return autoInterpreterState; +} + void _PyGILState_Fini(void) { PyThread_delete_key(autoTLSkey); + autoTLSkey = -1; autoInterpreterState = NULL; } @@ -784,8 +793,19 @@ PyGILState_GetThisThreadState(void) int PyGILState_Check(void) { - PyThreadState *tstate = GET_TSTATE(); - return tstate && (tstate == PyGILState_GetThisThreadState()); + PyThreadState *tstate; + + if (!_PyGILState_check_enabled) + return 1; + + if (autoTLSkey == -1) + return 1; + + tstate = GET_TSTATE(); + if (tstate == NULL) + return 0; + + return (tstate == PyGILState_GetThisThreadState()); } PyGILState_STATE |