Backport 52503:
Fix crash in test on HP-UX. Apparently, it's not possible to delete a lock if
it's held (even by the current thread).
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index edfe8ad..b11f0ae 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -667,6 +667,9 @@
PyThread_acquire_lock(thread_done, 1); /* wait for thread to finish */
Py_END_ALLOW_THREADS
+ /* Release lock we acquired above. This is required on HP-UX. */
+ PyThread_release_lock(thread_done);
+
PyThread_free_lock(thread_done);
Py_RETURN_NONE;
}