]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport [ 1010677 ] thread Module Breaks PyGILState_Ensure()
authorMark Hammond <mhammond@skippinet.com.au>
Wed, 1 Sep 2004 22:31:23 +0000 (22:31 +0000)
committerMark Hammond <mhammond@skippinet.com.au>
Wed, 1 Sep 2004 22:31:23 +0000 (22:31 +0000)
to the 2.3 maint branch.

Lib/test/test_capi.py
Modules/threadmodule.c

index 82bded41cfcba47cf20b2e7d98017a95a9500db9..95ec060a3ad24b46602062b6639750e39372228d 100644 (file)
@@ -43,3 +43,6 @@ except AttributeError:
 
 if have_thread_state:
     TestThreadState()
+    import threading
+    t = threading.Thread(target=TestThreadState)
+    t.start()
index 24a32ae3252772840cb30a9d9beb7ec02e88f1d7..ae79f24399190e05832991d423408b201156f69a 100644 (file)
@@ -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();
 }