From: Mark Hammond Date: Wed, 1 Sep 2004 22:31:23 +0000 (+0000) Subject: Backport [ 1010677 ] thread Module Breaks PyGILState_Ensure() X-Git-Tag: v2.3.5c1~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bb4d5d0152fac4e5b683f9513644e10e1bf1062;p=thirdparty%2FPython%2Fcpython.git Backport [ 1010677 ] thread Module Breaks PyGILState_Ensure() to the 2.3 maint branch. --- diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py index 82bded41cfcb..95ec060a3ad2 100644 --- a/Lib/test/test_capi.py +++ b/Lib/test/test_capi.py @@ -43,3 +43,6 @@ except AttributeError: if have_thread_state: TestThreadState() + import threading + t = threading.Thread(target=TestThreadState) + t.start() diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c index 24a32ae32527..ae79f2439919 100644 --- a/Modules/threadmodule.c +++ b/Modules/threadmodule.c @@ -172,11 +172,10 @@ static void t_bootstrap(void *boot_raw) { struct bootstate *boot = (struct bootstate *) boot_raw; - PyThreadState *tstate; + PyGILState_STATE gstate; PyObject *res; - tstate = PyThreadState_New(boot->interp); - PyEval_AcquireThread(tstate); + gstate = PyGILState_Ensure(); res = PyEval_CallObjectWithKeywords( boot->func, boot->args, boot->keyw); if (res == NULL) { @@ -201,8 +200,7 @@ t_bootstrap(void *boot_raw) Py_DECREF(boot->args); Py_XDECREF(boot->keyw); PyMem_DEL(boot_raw); - PyThreadState_Clear(tstate); - PyThreadState_DeleteCurrent(); + PyGILState_Release(gstate); PyThread_exit_thread(); }