Skip to content

Commit ce0c226

Browse files
committed
Add docs about exception capturing in PyQt5.5
1 parent 70437e3 commit ce0c226

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

docs/virtual_methods.rst

+13-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ naturally in your python code::
1616
print('mouse released at: %s' % ev.pos())
1717

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

2325
This might be surprising for python users which are used to exceptions
2426
being raised at the calling point: for example, the following code will just
@@ -61,4 +63,12 @@ Or even disable it for your entire project in your ``pytest.ini`` file:
6163
[pytest]
6264
qt_no_exception_capture = 1
6365
64-
This might be desirable if you plan to install a custom exception hook.
66+
This might be desirable if you plan to install a custom exception hook.
67+
68+
69+
.. note::
70+
71+
Starting with ``PyQt5.5``, exceptions raised during virtual methods will
72+
actually trigger an ``abort()``, crashing the Python interpreter. For this
73+
reason, disabling exception capture in ``PyQt5.5+`` is not recommended
74+
unless you install your own exception hook.

0 commit comments

Comments
 (0)