From 892be2b8024d391dbc78028a2e99b7800db2ea99 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 27 Jan 2025 15:10:39 +0100 Subject: [PATCH] Fix crash when using directors in Python without limited API Call correct functions when unlocking/destroying a mutex implemented using Python API: they were accidentally exchanged in 21f1c923c (Make directors implementation for Python work with limited API, 2019-12-23) resulting in crashes when using directors and threads together. Closes #2889, #3112. --- CHANGES.current | 4 ++++ Lib/python/director_py_mutex.swg | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f804f39e4c..f366a4f744 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.4.0 (in progress) =========================== +2025-01-27: StefanBattmer + [Python] #2889 Fix regression when using directors and threads + but not using limited API. + 2024-12-07: arbrauns [Lua] #3083 Fix "unsigned long long" being interpreted as "signed long long". diff --git a/Lib/python/director_py_mutex.swg b/Lib/python/director_py_mutex.swg index 9e271455a8..5bb0f83f26 100644 --- a/Lib/python/director_py_mutex.swg +++ b/Lib/python/director_py_mutex.swg @@ -16,9 +16,9 @@ namespace Swig { PyThread_type_lock mutex_; public: Mutex() : mutex_(PyThread_allocate_lock()) {} - ~Mutex() { PyThread_release_lock(mutex_); } + ~Mutex() { PyThread_free_lock(mutex_); } void lock() { PyThread_acquire_lock(mutex_, WAIT_LOCK); } - void unlock() { PyThread_free_lock(mutex_); } + void unlock() { PyThread_release_lock(mutex_); } }; } #endif