]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport 2.39:
authorGuido van Rossum <guido@python.org>
Tue, 8 Feb 2005 15:01:35 +0000 (15:01 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 8 Feb 2005 15:01:35 +0000 (15:01 +0000)
Close the discussion in SF bug 1069160.

Python/pystate.c

index 182560748fe432f74fb523429b77294075a86db9..255cf7e86e82a8492f52515a162f42b297581687 100644 (file)
@@ -320,7 +320,7 @@ PyThreadState_GetDict(void)
 
 /* Asynchronously raise an exception in a thread.
    Requested by Just van Rossum and Alex Martelli.
-   To prevent naive misuse, you must write your own exception
+   To prevent naive misuse, you must write your own extension
    to call this.  Must be called with the GIL held.
    Returns the number of tstates modified; if it returns a number
    greater than one, you're in trouble, and you should call it again
@@ -332,6 +332,7 @@ PyThreadState_SetAsyncExc(long id, PyObject *exc) {
        PyInterpreterState *interp = tstate->interp;
        PyThreadState *p;
        int count = 0;
+       HEAD_LOCK();
        for (p = interp->tstate_head; p != NULL; p = p->next) {
                if (p->thread_id != id)
                        continue;
@@ -340,6 +341,7 @@ PyThreadState_SetAsyncExc(long id, PyObject *exc) {
                p->async_exc = exc;
                count += 1;
        }
+       HEAD_UNLOCK();
        return count;
 }