[PyKDE] problem with exceptions within events
Giovanni Bajo
rasky at develer.com
Thu Feb 24 12:11:09 GMT 2005
Toby Dickenson <tdickenson at devmail.geminidataloggers.co.uk> wrote:
> Ive attached a test script based on your original report. I cant reproduce
the
> problem here with sip 4.0.1, PyQt 3.1.2, qt 3.3.3
Thanks for doing this.
The problem can be reproduced if you convert your app.processEvents() call
to app.exec_loop(). In that case, I cannot see the traceback anymore.
(Again, I'm using Qt 3.3.4, PyQt 3.14, SIP 4.2).
There is also another difference: on my computer, the script aborts whenever
it hits the first exception. For instance, it aborts on the app.sendEvent()
call, and I never see the following string "you should see an exception
above" on the screen. Thus, to reproduce the problem with exec_loop(), I
have commented out the first sendEvent() call.
I don't know if it is related, but my Qt is compiled with -no-exceptions. I
know that Python and C++ exceptions are not related, but I don't know if SIP
converts exceptions on bindings boundaries (I know other similar wrapping
tools do that). Could Phil enlighten us on this?
To sum it up. With this script:
=========================================================
import sys
def foo(*args):
print "except hook"
sys.excepthook = foo
from qt import *
app=QApplication([])
class W(QWidget):
def customEvent(self, e):
print >> sys.stderr,'in event handler....'
1/0 # gratuitous exception.... lets see how it gets handled
w = W()
#print >> sys.stderr,'about to send event....'
#app.sendEvent(w, QCustomEvent(QEvent.User))
#print >> sys.stderr,'you should see an exception logged above\n\n'
print >> sys.stderr, 'about to post event, should see nothing yet....'
app.postEvent(w, QCustomEvent(QEvent.User))
print >> sys.stderr, 'about to process that event....'
app.exec_loop()
print >> sys.stderr,'you *should* see the same exception logged again.'
print >> sys.stderr,'"Giovanni Bajo" <rasky at develer.com> reports that it is
omitted\n\n'
print 'done'
=========================================================
I get this output:
=========================================================
about to post event, should see nothing yet....
about to process that event....
in event handler....
=========================================================
--
Giovanni Bajo
More information about the PyQt
mailing list