[PyKDE] problem with exceptions within events

Giovanni Bajo rasky at develer.com
Wed Feb 23 17:55:38 GMT 2005


Hello,

it seems that Python exceptions generated within event handlers do not get
propagated correctly. We use a sys.excepthook to abort gracefully with a
messagebox from our application, and this seems to work in most cases but
not within event handlers. For instance:


>>> from qt import *
>>> app=QApplication([])
>>> class W(QWidget):
...     def customEvent(self, e):
...             print "1"
...             syntax_error
...             print "2"
...
>>> w = W()
>>> app.sendEvent(w, QCustomEvent(QEvent.User))
1
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 4, in customEvent
NameError: global name 'syntax_error' is not defined
>>> app.postEvent(w, QCustomEvent(QEvent.User))
>>> app.exec_loop()
1


Is this a known problem? Surely it is a serious one since we cannot afford
to ignore exceptions.

This is with SIP 4.2, PyQT 3.14.
-- 
Giovanni Bajo




More information about the PyQt mailing list