Bug: QApplication() raise nothing on tty

Florian Bruhin me at the-compiler.org
Sun Jul 9 13:52:16 BST 2023


> On 2023-07-08 23:33 Florian Bruhin <me at the-compiler.org> wrote:
> > I don't think this is a bug.
> 
> No doubt it is one. It crashes the whole Python instance.

That's just not how bindings to another language work.
You don't get to use C++ bindings and then ignore the C++ side of what's
happening.

> > > When I try to create an instance of QApplication (PyQt5) the whole 
> > > Python instances crashes. I tried this in a tty terminal.
> > > 
> > > But I would expect that QApplication.__init__() raise an Exception
> > > (e.g. RunTimeException) if something is wrong.
> > > 
> > > Currently I have to workaround such situations via checking
> > > environment variables which blow up the code. I would better try to
> > > use a try...except solution.
> > 
> > What situations exactly? In general, there is no way for PyQt to know
> > whether Qt will call abort(), and there is no way for it to react to
> > it when it happens.
> 
> I don't understand your comment about abort().

It's a C(++) function which aborts the current process:
https://en.cppreference.com/w/c/program/abort

Qt calls it on fatal errors. There is no way (or at least no way that's
not a giant hack) for PyQt to catch that happening, because at the time
Qt calls abort(), there is no more Python code being run.

> I described the "situation". Run PyQt script in a tty or on a system
> with X/Wayland installed.

You really did not, no. I'm running a PyQt application (both my browser
and my mail client) on a system with X installed and, surprise, it
works.

Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230709/ec4b90b6/attachment.sig>


More information about the PyQt mailing list