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

QDomElement setAttribute() does not work with float, int

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.15.1
    • 5.14.2
    • PySide, Shiboken
    • None
    • Linux/X11, macOS
    • 8d1fcdf94f2c368f7877f9e0cb2995e00f103e1a (pyside/pyside-setup/5.15)

    Description

      Attempting to use QDomElement.setAttribute() with a value other than uint or str results in an OverflowError from libshiboken.  This happens with python 3.6, 3.7 and 3.8 on both MacOs Catalina, and Linux.  Qt version is 5.14.2 in both cases.

      The attached program demonstrates the problem.  The console displays:

       

      % ./pyside2_setattribute_demo.py               

      ./pyside2_setattribute_demo.py:16: RuntimeWarning: libshiboken: Overflow: Value -123 exceeds limits of type  [unsigned] "j" (4bytes).

        myelem.setAttribute("attr2", -123.45)  # OverflowError

      Traceback (most recent call last):

        File "./pyside2_setattribute_demo.py", line 16, in <module>

          myelem.setAttribute("attr2", -123.45)  # OverflowError

      OverflowError

       

      It looks like float values are (incorrectly) cast to an int, and then Shiboken casts the int to an unsigned int and fails.

       

      Changing the PySide2 import to PyQt5 allows the script to work as intended.

       

       

      Attachments

        1. pyside1372_diag.diff
          5 kB
        2. pyside1372.py
          0.5 kB
        3. pyside2_setattribute_demo.py
          0.4 kB
        For Gerrit Dashboard: PYSIDE-1372
        # Subject Branch Project Status CR V

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            stoogy73 stoogy73@googlemail.com Gilson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes