bpo-33316: PyThread_release_lock always fails (GH-6541)
Use correct interpretation of return value from APIs.
(cherry picked from commit 05e922136a3286893bd489a8f2ecfa0dba4da368)
Co-authored-by: native-api <ivan_pozdeev@mail.ru>
diff --git a/Python/thread_nt.h b/Python/thread_nt.h
index 61fa861..56295d0 100644
--- a/Python/thread_nt.h
+++ b/Python/thread_nt.h
@@ -104,8 +104,9 @@
if (PyMUTEX_LOCK(&mutex->cs))
return FALSE;
mutex->locked = 0;
- result = PyCOND_SIGNAL(&mutex->cv);
- result &= PyMUTEX_UNLOCK(&mutex->cs);
+ /* condvar APIs return 0 on success. We need to return TRUE on success. */
+ result = !PyCOND_SIGNAL(&mutex->cv);
+ PyMUTEX_UNLOCK(&mutex->cs);
return result;
}