Details
Description
PySide6 does not gracefully handle warnings-as-errors, which is common for example in `pytest` to make sure errors don't creep into code. Consider this case:
>>> from PySide6.QtCore import QEvent
>>> from PySide6.QtGui import QMouseEvent
>>> from PySide6.QtCore import Qt, QPointF
>>> pos = QPointF(288.683594, 4.558000)
>>> modifier = Qt.KeyboardModifier.NoModifier
>>> QMouseEvent(QEvent.Type.MouseButtonPress, pos, Qt.MouseButton.NoButton, Qt.MouseButton.NoButton, modifier)
<stdin>:1: DeprecationWarning: Function: 'QMouseEvent.QMouseEvent(QEvent.Type type, const QPointF & localPos, Qt.MouseButton button, QFlags<Qt.MouseButton> buttons, QFlags<Qt.KeyboardModifier> modifiers, const QPointingDevice * device)' is marked as deprecated, please check the documentation for more information.
Okay, a DeprecationWarning is reasonable here. However, when treating warnings-as-errors using pytest, or in plain Python code, things go wrong. Using the code snippet above but adding these two lines before instantiating the QMouseEvent:
>>> import warnings
>>> warnings.simplefilter('error')
We get:
>>> QMouseEvent(QEvent.Type.MouseButtonPress, pos, Qt.MouseButton.NoButton, Qt.MouseButton.NoButton, modifier)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: /Users/runner/miniforge3/conda-bld/python-split_1661199920571/work/Objects/longobject.c:1127: bad argument to internal function
This can lead to hard-to-interpret tracebacks like:
Attachments
Issue Links
- resulted in
-
PYSIDE-2142 passing cpp exported enum to cpp function as param (from python) prints error
- Closed