diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-03-14 21:07:55 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-03-14 21:07:55 (GMT) |
commit | 8a1be61849341528c866924cf69d378ce7790889 (patch) | |
tree | 0b59fbc22edbd703ded539758aae78382d4eec7d /Python/pylifecycle.c | |
parent | 08572f68a980576e883e4eba1227b59782d5192e (diff) | |
download | cpython-8a1be61849341528c866924cf69d378ce7790889.zip cpython-8a1be61849341528c866924cf69d378ce7790889.tar.gz cpython-8a1be61849341528c866924cf69d378ce7790889.tar.bz2 |
Add more checks on the GIL
Issue #10915, #15751, #26558:
* PyGILState_Check() now returns 1 (success) before the creation of the GIL and
after the destruction of the GIL. It allows to use the function early in
Python initialization and late in Python finalization.
* Add a flag to disable PyGILState_Check(). Disable PyGILState_Check() when
Py_NewInterpreter() is called
* Add assert(PyGILState_Check()) to: _Py_dup(), _Py_fstat(), _Py_read()
and _Py_write()
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index aaf5811..4fc6a15 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -692,6 +692,7 @@ Py_FinalizeEx(void) /* Delete current thread. After this, many C API calls become crashy. */ PyThreadState_Swap(NULL); + PyInterpreterState_Delete(interp); #ifdef Py_TRACE_REFS @@ -743,6 +744,10 @@ Py_NewInterpreter(void) if (!initialized) Py_FatalError("Py_NewInterpreter: call Py_Initialize first"); + /* Issue #10915, #15751: The GIL API doesn't work with multiple + interpreters: disable PyGILState_Check(). */ + _PyGILState_check_enabled = 0; + interp = PyInterpreterState_New(); if (interp == NULL) return NULL; |