Lee Merrill wrote:
Thanks, my problem in either approach appears to be that _PyThreadState_Current is NULL, which PyThreadState_Get() even considers a fatal error! But I'm using this variable in the signal handler, so I don't see how it's getting reset due to the SEGV...
It depends on where the SEGV happens. The wxPython wrappers will release Python's Global Interpreter Lock (which clears the current thread state) whenever a call is made to wx C++ code, and then reacquire it when returning to Python. It also acquires and releases the GIL when making a call to Python code or when manipulating Python objects.
I've got some helper functions that I call to restore the GIL and the interpreter state, but if you are putting this function in wxWidgets then I'm not sure you'll be able to call it directly because it actually accesses the function via a function pointer imported from the wx._core_ module. So instead I would try wrapping your block of calls to the Py functions with these:
PyGILState_STATE state = PyGILState_Ensure();
...
PyGILState_Release(state);
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!