Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2136

warning-as-error causes SystemError

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.5.0, 6.4.2
    • 6.4.0
    • PySide
    • None
    • All
    • f36f85d0a58b742b9fe0c947a3f402563de4e389, c8513e0bb (6.4), 340e9bfb2 (dev), 8dc6fa902 (6.4)

    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:

       

      https://dev.azure.com/mne-tools/mne-python/_build/results?buildId=22819&view=logs&jobId=d2de176e-a8da-5d2d-82f1-e561f5072d99&j=d2de176e-a8da-5d2d-82f1-e561f5072d99&t=f4deb373-ce79-59c7-15db-2653b3e8f79f

      Attachments

        1. pyside2136_diag.diff
          1.0 kB
        2. pyside2136_enum_stack.txt
          22 kB
        3. pyside2136.py
          0.6 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kleint Friedemann Kleint
              larsoner Eric Larson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes