From 822e03eeffe940efdcae10f44f46bd49e6f76131 Mon Sep 17 00:00:00 2001
From: Robin Dunn <robin@alldunn.com>
Date: Sat, 12 Mar 2005 21:03:18 +0000
Subject: [PATCH] Don't use the PyGILState_* APIs with Python 2.3, it causes a
 problem with Boa's debugger.  :-(

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32791 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 wxPython/include/wx/wxPython/wxPython_int.h | 11 +++++++++--
 wxPython/src/helpers.cpp                    |  4 +++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/wxPython/include/wx/wxPython/wxPython_int.h b/wxPython/include/wx/wxPython/wxPython_int.h
index f4afefcb7f..b91f3e7317 100644
--- a/wxPython/include/wx/wxPython/wxPython_int.h
+++ b/wxPython/include/wx/wxPython/wxPython_int.h
@@ -141,8 +141,15 @@ bool wxPySwigInstance_Check(PyObject* obj);
 // blocking threads when calling back into Python. Using them instead of my
 // home-grown hacks greatly simplifies wxPyBeginBlockThreads and
 // wxPyEndBlockThreads.
-
-#if PY_VERSION_HEX < 0x02030000
+//
+// Unfortunatly there is a bug somewhere when using these new APIs on Python
+// 2.3.  It manifests in Boa Constructor's debugger where it is unable to stop
+// at breakpoints located in event handlers.  I think that the cause may be
+// something like the original PyThreadState for the main thread is not being
+// restored for the callbacks, but I can't see where that could be
+// happening...  So we'll only activate this new change for Python 2.4+  :-(
+
+#if PY_VERSION_HEX < 0x02040000
 #define wxPyUSE_GIL_STATE 0
 typedef bool wxPyBlock_t;
 #else
diff --git a/wxPython/src/helpers.cpp b/wxPython/src/helpers.cpp
index 9b7e3efb6d..2a568e3e38 100644
--- a/wxPython/src/helpers.cpp
+++ b/wxPython/src/helpers.cpp
@@ -544,8 +544,10 @@ void __wxPyPreStart(PyObject* moduleDict)
 #endif
 
 #ifdef WXP_WITH_THREAD
+#if wxPyUSE_GIL_STATE
+    PyEval_InitThreads();
+#else
     PyEval_InitThreads();
-#if !wxPyUSE_GIL_STATE
     wxPyTStates = new wxPyThreadStateArray;
     wxPyTMutex = new wxMutex;
 
-- 
2.47.2