Problem in _tkinter.c with extending both tk and python with C++

Jyrki Alakuijala Jyrki.Alakuijala at mail.dosetek.varian.com
Thu Jun 22 03:31:40 EDT 2000


I have an old python/tkinter application that used to work fine
with Python 1.4 and 1.5. Roughly one year ago it got
broken. The application is mostly C++ and Python with some
"embedded" tcl. Now, with 1.5.2 the program crashes
similarly in both Windows NT and Linux environments.

The problem occurs with the following pattern:
First, I load a (self-made) tk widget as a dynamic library.

Second, I load the (self-made) python extensions as dynamic
libraries.

Third, I make an operation in the user interface that
starts as a Tk-event, going to python. Python updates
my widget, which calls C++ code, which calls
(Tcl_VarEval) which tries to visit Python code.
This is when the program crashes.

The error message it gives before termination is:
Fatal Python error: PyEval_RestoreThread: NULL tstate

I believe this has something to do with the thread
safety of tkinter (ENTER_PYTHON and
LEAVE_PYTHON). Perhaps I should take these
macros into my code for visiting Tcl code from C++.
However, I cannot get access the Tcl-lock declared in
_tkinter.c, because it is static.

What should I do to get the code working with
newer releases of Python? Should I give up with
Tk and move to one of the newer UI libraries?
Should I write my own _tkinter.c?
Have I messed it up somewhere else?

--Jyrki





More information about the Python-list mailing list