[PyKDE] PyEval_RestoreThread Error

Hans-Peter Jansen hpj at urpla.net
Thu Aug 21 15:06:01 BST 2003


Hi Michael,

I had similar problems with very simple test scripts, which resulted 
from races in the dtors of python and pyqt classes. You can prove this 
theory with this patch:

--- bug_test.py 2003-08-21 14:34:28.000000000 +0200
+++ bug_testx.py      2003-08-21 14:50:43.000000000 +0200
@@ -27,7 +27,7 @@
 
         self.connect(self.PrintButton,SIGNAL("clicked()"),self.Print)
         self.connect(self.QuitButton,SIGNAL("clicked()"),\
-                     self,SLOT("close()"))
+                     qApp.quit)
 
     def languageChange(self):
         self.setCaption(self.__tr("UIMain"))

Alt., also try calling sys.exit(0). Funny was, when the scripts got 
more complex, say by adding modules, those problems disappeared, too.
BTW: on Python 2.2.2, Qt 3.1.1, sip/PyQt 3.8 ii works flawlessly both 
ways, (after fixing the obvious intention error)..

Pete

On Thursday 21 August 2003 13:05, Michael Andrews wrote:
> I don't know if this is a Python, Qt, or PyQt issue.  I thought I'd
> start with PyQt and we'll see where it leads.  I am trying to build a
> new Python/Qt environment consisting of:
>   Python 2.3, Qt-3.2.0, sip-3.8, and PyQt-3.8
> When I run the bug_test.py script below and then immediately press
> the Quit button, python dumps core with the following error:
>
>   Fatal Python error: PyEval_RestoreThread: NULL tstate
>
> I have reproduced the problem under HPUX 11 and Redhat Linux-9, and
> the 'application' works fine under Python 2.2.3, Qt 3.1.2, sip-3.6,
> and PyQt-3.6.
>
> The problem appears to be the fact that my UIMainC class (the
> controller) has a member which is the AppClass and the AppClass has a
> member which is the controller.  If I remove the UIMainC.app

Parse error: UIMainC.app not found ;-)

> everything works.
>
> Any suggestions on how to proceed?




More information about the PyQt mailing list