Skip to content

Commit

Permalink
Add docs about exception capturing in PyQt5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed Aug 1, 2015
1 parent 70437e3 commit ce0c226
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions docs/virtual_methods.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ naturally in your python code::
print('mouse released at: %s' % ev.pos())

This works fine, but if python code in Qt virtual methods raise an exception
``PyQt`` and ``PySide`` will just print the exception traceback to standard
``PyQt4`` and ``PySide`` will just print the exception traceback to standard
error, since this method is called deep within Qt's even loop handling and
exceptions are not allowed at that point.
exceptions are not allowed at that point. In ``PyQt5.5+``, exceptions in
virtual methods will by default call ``abort()``, which will crash the
interpreter.

This might be surprising for python users which are used to exceptions
being raised at the calling point: for example, the following code will just
Expand Down Expand Up @@ -61,4 +63,12 @@ Or even disable it for your entire project in your ``pytest.ini`` file:
[pytest]
qt_no_exception_capture = 1
This might be desirable if you plan to install a custom exception hook.
This might be desirable if you plan to install a custom exception hook.


.. note::

Starting with ``PyQt5.5``, exceptions raised during virtual methods will
actually trigger an ``abort()``, crashing the Python interpreter. For this
reason, disabling exception capture in ``PyQt5.5+`` is not recommended
unless you install your own exception hook.

0 comments on commit ce0c226

Please sign in to comment.