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

List:       pykde
Subject:    [PyQt] QApplication.notify exception?
From:       Matic Kukovec <kukovecmatic () hotmail ! com>
Date:       2019-05-28 17:41:24
Message-ID: VI1PR01MB5344C32288CD4EAE7C279289D71E0 () VI1PR01MB5344 ! eurprd01 ! prod ! exchangelabs ! com
[Download RAW message or body]

On Sun, May 26, 2019 at 04:52:20PM -0400, Kyle Altendorf wrote:
> On 2019-05-26 16:37, Matic Kukovec wrote:
>
> > Hi guys,
> >
> > I have an application that runs without a problem on Windows, but on
> > Linux it shows this message on exit:
> >
> > > Qt has caught an exception thrown from an event handler. Throwing
> > > exceptions from an event handler is not supported in Qt.
> > > You must not let any exception whatsoever propagate through Qt code.
> > > If that is not possible, in Qt 5 you must at least reimplement
> > > QCoreApplication::notify() and catch all exceptions there.
>
> I use sys.excepthook to provide a log and dialog for otherwise unhandled
> Python exceptions.  Maybe see if that can at least let you see what
> exception is causing trouble?  But I honestly haven't ever seen a referen=
ce
> to this message before...  :|

That message is coming from Qt, which doesn't know about Python exceptions.

I'm guessing it's referring to C++ exceptions, which you won't catch in Pyt=
hon
via an excepthook or "except".

So the question is why there's a C++ exception thrown, and from where... No
idea how to debug that to be honest. Maybe you can get gdb to break on any
exception or something?

Florian

The first step is to get some more information regarding the exception
trace. The exception traceback has tb_frame and tb_next attributes to
build a frames stack. Each frame has its own frame.f_code.co_name,
frame.f_code.co_filename, frame.f_lineno and local stack variables
(frame.f_locals).

--
Giuseppe Corbelli

Thanks for the suggestions guys!

I added a faulthandler to my application and added an exception handler in =
an overridden
QApplication.notify and it pointed me to a queue implementation i have, tha=
t uses signals/slots for input
and output, and it seems that a exception happens in there and only on Linu=
x.
I'm still hunting it down, but at least now I know where to look.

This SO post also helped me to figure out that exceptions in a slot are som=
etimes not propagated up:
https://stackoverflow.com/questions/18740884/preventing-pyqt-to-silence-exc=
eptions-occurring-in-slots


Thanks again,
Matic


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} \
</style> </head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> <blockquote style="border-color: rgb(200, 200, 200); border-left: 3px \
solid rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, \
102);"> <div>
<div>
<div>
<div><font size="2"><span style="font-size:11pt">On Sun, May 26, 2019 at 04:52:20PM \
-0400, Kyle Altendorf wrote:<br> </span></font></div>
</div>
</div>
</div>
<div>
<div>
<div><font size="2"><span style="font-size:11pt">&gt; On 2019-05-26 16:37, Matic \
Kukovec wrote:<br> &gt; <br>
&gt; &gt; Hi guys,<br>
&gt; &gt; <br>
&gt; &gt; I have an application that runs without a problem on Windows, but on<br>
&gt; &gt; Linux it shows this message on exit:<br>
&gt; &gt; <br>
&gt; &gt; &gt; Qt has caught an exception thrown from an event handler. Throwing<br>
&gt; &gt; &gt; exceptions from an event handler is not supported in Qt.<br>
&gt; &gt; &gt; You must not let any exception whatsoever propagate through Qt \
code.<br> &gt; &gt; &gt; If that is not possible, in Qt 5 you must at least \
reimplement<br> &gt; &gt; &gt; QCoreApplication::notify() and catch all exceptions \
there.<br> &gt; <br>
&gt; I use sys.excepthook to provide a log and dialog for otherwise unhandled<br>
&gt; Python exceptions.&nbsp; Maybe see if that can at least let you see what<br>
&gt; exception is causing trouble?&nbsp; But I honestly haven't ever seen a \
reference<br> &gt; to this message before...&nbsp; :|<br>
<br>
That message is coming from Qt, which doesn't know about Python exceptions.<br>
<br>
I'm guessing it's referring to C&#43;&#43; exceptions, which you won't catch in \
Python<br> via an excepthook or &quot;except&quot;.<br>
<br>
So the question is why there's a C&#43;&#43; exception thrown, and from where... \
No<br> idea how to debug that to be honest. Maybe you can get gdb to break on any<br>
exception or something?<br>
<br>
</span></font></div>
<div><font size="2"><span style="font-size:11pt">Florian</span></font></div>
</div>
</div>
</blockquote>
<div>
<blockquote style="border-color: rgb(200, 200, 200); border-left: 3px solid rgb(200, \
200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);"> <font \
size="2"><span style="font-size:11pt"><br> The first step is to get some more \
information regarding the exception <br> trace. The exception traceback has tb_frame \
and tb_next attributes to <br> build a frames stack. Each frame has its own \
frame.f_code.co_name, <br> frame.f_code.co_filename, frame.f_lineno and local stack \
variables <br> (frame.f_locals).<br>
<br>
-- <br>
</span></font>
<div><font size="2"><span style="font-size:11pt">Giuseppe Corbelli</span></font><font \
size="2"><span style="font-size:11pt"><br> </span></font></div>
</blockquote>
<div><br>
</div>
<div>Thanks for the suggestions guys!</div>
<div><br>
</div>
<div>I added a <i>faulthandler </i>to my application and added an exception handler \
in an overridden<br> </div>
<div><i>QApplication.notify</i> and it pointed me to a queue implementation i have, \
that uses signals/slots for input</div> <div>and output, and it seems that a \
exception happens in there and only on Linux.</div> <div>I'm still hunting it down, \
but at least now I know where to look.</div> <div><br>
</div>
<div>This SO post also helped me to figure out that exceptions in a slot are \
sometimes not propagated up:</div> <div><a \
href="https://stackoverflow.com/questions/18740884/preventing-pyqt-to-silence-exceptions-occurring-in-slots" \
id="LPNoLP417274">https://stackoverflow.com/questions/18740884/preventing-pyqt-to-silence-exceptions-occurring-in-slots</a><br>
 </div>
<br>
<div><br>
</div>
<div>Thanks again,<br>
</div>
<div>Matic<br>
</div>
</div>
<br>
</div>
</body>
</html>


[Attachment #4 (unknown)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://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