[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Exception handling hook
From:       "Arve Knudsen" <arve.knudsen () gmail ! com>
Date:       2007-05-26 16:25:30
Message-ID: a0d6258d0705260925o1e6c9eddl3aba5f6c1c054d3b () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On 5/25/07, Detlev Offenbach <detlev@die-offenbachs.de> wrote:
> On Donnerstag, 24. Mai 2007, Arve Knudsen wrote:
> > Hi Detlev
> >
> > On 5/24/07, Detlev Offenbach <detlev@die-offenbachs.de> wrote:
> > > On Mittwoch, 23. Mai 2007, Arve Knudsen wrote:
> > > > Is it possible to register a hook with QApplication in order to be
> > >
> > > notified
> > >
> > > > of an unhandled exception? Currently, all that happens when an
> > > > exception propagates to the event loop is that it gets printed in
the
> > > > console,
> > >
> > > which
> > >
> > > > is not very helpful. How do others cope with unhandled exceptions in
> > >
> > > PyQt
> > >
> > > > applications?
> > > >
> > > > Best regards,
> > > > Arve Knudsen
> > >
> > > See eric4 as an example.
> >
> > I'm not at all familiar with eric4. Could you please elaborate as to
where
> > I can look in eric4's source code (I assume this is what you mean)?
Also, I
> > take it eric4 does something more advanced than override sys.excepthook?
> >
> > Thanks,
> > Arve
> >
> > Detlev
> >
> > > --
> > > Detlev Offenbach
> > > detlev@die-offenbachs.de
> def main():
>     """
>     Main entry point into the application.
>     """
>     sys.excepthook = excepthook
>

Can you tell me what happens if you call a piece of Qt code
from Python which in turns invokes a Python callback, and the
latter raises an exception? In my experience sys.excepthook is useless
in this scenario, because when control returns from the
last Python callback, the exception is not propagated (i.e., there is normal
flow of control).

Arve

[Attachment #5 (text/html)]

<br>On 5/25/07, Detlev Offenbach &lt;<a \
href="mailto:detlev@die-offenbachs.de">detlev@die-offenbachs.de</a>&gt; \
wrote:<br>&gt; On Donnerstag, 24. Mai 2007, Arve Knudsen wrote:<br>&gt; &gt; Hi \
Detlev<br>&gt; &gt;<br>&gt; &gt; On 5/24/07, Detlev Offenbach &lt; <a \
href="mailto:detlev@die-offenbachs.de">detlev@die-offenbachs.de</a>&gt; \
wrote:<br>&gt; &gt; &gt; On Mittwoch, 23. Mai 2007, Arve Knudsen wrote:<br>&gt; &gt; \
&gt; &gt; Is it possible to register a hook with QApplication in order to be <br>&gt; \
&gt; &gt;<br>&gt; &gt; &gt; notified<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; of an \
unhandled exception? Currently, all that happens when an<br>&gt; &gt; &gt; &gt; \
exception propagates to the event loop is that it gets printed in the <br>&gt; &gt; \
&gt; &gt; console,<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; which<br>&gt; &gt; \
&gt;<br>&gt; &gt; &gt; &gt; is not very helpful. How do others cope with unhandled \
exceptions in<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; PyQt <br>&gt; &gt; &gt;<br>&gt; \
&gt; &gt; &gt; applications?<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; Best \
regards,<br>&gt; &gt; &gt; &gt; Arve Knudsen<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; See \
eric4 as an example.<br>&gt; &gt; <br>&gt; &gt; I&#39;m not at all familiar with \
eric4. Could you please elaborate as to where<br>&gt; &gt; I can look in eric4&#39;s \
source code (I assume this is what you mean)? Also, I<br>&gt; &gt; take it eric4 does \
something more advanced than override  sys.excepthook?<br>&gt; &gt;<br>&gt; &gt; \
Thanks,<br>&gt; &gt; Arve<br>&gt; &gt;<br>&gt; &gt; Detlev<br>&gt; &gt;<br>&gt; &gt; \
&gt; --<br>&gt; &gt; &gt; Detlev Offenbach<br>&gt; &gt; &gt; <a \
href="mailto:detlev@die-offenbachs.de"> detlev@die-offenbachs.de</a><br>&gt; def \
main():<br>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&quot;<br>&gt; \
&nbsp;&nbsp;&nbsp;&nbsp;Main entry point into the application.<br>&gt; \
&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&quot;<br>&gt; \
&nbsp;&nbsp;&nbsp;&nbsp;sys.excepthook = excepthook<br>&gt; \
<br><br>Can&nbsp;you&nbsp;tell&nbsp;me&nbsp;what&nbsp;happens&nbsp;if&nbsp;you&nbsp;call&nbsp;a&nbsp;piece&nbsp;of&nbsp;Qt&nbsp;code \
from&nbsp;Python&nbsp;which&nbsp;in&nbsp;turns&nbsp;invokes&nbsp;a&nbsp;Python&nbsp;callback,&nbsp;and&nbsp;the \
latter&nbsp;raises&nbsp;an&nbsp;exception?&nbsp;In&nbsp;my&nbsp;experience&nbsp; \
sys.excepthook&nbsp;is&nbsp;useless&nbsp;in&nbsp;this&nbsp;scenario,&nbsp;because&nbsp;when&nbsp;control&nbsp;returns&nbsp;from&nbsp;the \
last&nbsp;Python&nbsp;callback,&nbsp;the&nbsp;exception&nbsp;is&nbsp;not&nbsp;propagated \
(i.e., there is normal flow of control).&nbsp;<br><br>Arve<br>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic