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

PySide issue with Py_REFCNT() on Python 3.10

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2
    • Fix Version/s: None
    • Component/s: Build System
    • Labels:
      None
    • Platform/s:
      All

      Description

      PySide2 fails to build with Python 3.10 on "Py_REFCNT(ob) = 1;" in finalizeStaticStrings() of sources/shiboken2/libshiboken/sbkstring.cpp. In Python 3.10, it's no longer possible to use the Py_REFCNT() macro to set an object reference count (only use it to get an object reference count). The Py_SET_REFCNT() function must now be used instead (function available since Python 3.9).

       

      Moreover, interned strings are now cleared at Python exit since Python 3.10. So it's unsafe to set directly a static string reference count to 1 and call Py_DECREF() on it to destroy it. Python is likely to crash in this case.

       

      I suggest to simply use call Py_DECREF() twice on static strings in finalizeStaticStrings(): see attached patch.

       

      I tested the patch on the Fedora Python 3.10 COPR and the package built successfully with my patch (but I did not test an application using PySide).

       

      I chose to only change the behavior on Python 3.10 and newer, since interned strings were not cleared at exit on Python 3.9 and older.

       

      References:

       

        Attachments

        1. python310.patch
          0.6 kB
          Victor Stinner

          Issue Links

          For Gerrit Dashboard: PYSIDE-1436
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              ctismer Christian Tismer
              Reporter:
              vstinner Victor Stinner
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There is 1 open Gerrit change