Details
-
Bug
-
Resolution: Done
-
P2: Important
-
6.1.0
-
None
-
-
81e9cff884d6b03cdf64a5dd6ec6564d99177e0c (pyside/pyside-setup/dev)
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:
- Py_SET_REFCNT() function: https://docs.python.org/dev/c-api/structures.html#c.Py_SET_REFCNT
- What's New in Python 3.10: Py_REFCNT() change https://docs.python.org/dev/whatsnew/3.10.html#id2
- Python 3.10 releases interned strings at exit: https://github.com/python/cpython/commit/666ecfb0957a2fa0df5e2bd03804195de74bdfbf
- Fedora downstream issue: https://bugzilla.redhat.com/show_bug.cgi?id=1902618
- Fedora fix using my patch: https://src.fedoraproject.org/rpms/python-pyside2/pull-request/7
Attachments
Issue Links
- relates to
-
PYSIDE-1632 5.15 / Py3.9.6 doesnt build on windows10 msvc2019
- Closed
For Gerrit Dashboard: PYSIDE-1436 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
325031,2 | WIP: shiboken: make static strings independent from Python 3.10 | dev | pyside/pyside-setup | Status: ABANDONED | -2 | 0 |
348390,13 | py3.10-prep: Finally support Python 3.10 | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
365002,5 | py3.10-prep: re-implement zip import | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
365007,4 | py3.10-prep: reset the type cache after feature switching | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
365403,4 | py3.10-prep: Fix parser.py for changed typing module | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
366294,3 | py3.10-prep: Fix a very old refcounting error in time_test.py | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
366352,2 | py3.10-prep: Fix a binary operator bug in cppgenerator.py | dev | pyside/pyside-setup | Status: MERGED | +2 | 0 |
388405,4 | py3.10-prep: reset the type cache after feature switching | tqtc/lts-5.15 | pyside/tqtc-pyside-setup | Status: MERGED | +2 | 0 |
388406,4 | py3.10-prep: Fix parser.py for changed typing module | tqtc/lts-5.15 | pyside/tqtc-pyside-setup | Status: MERGED | +2 | 0 |
388407,4 | py3.10-prep: Finally support Python 3.10 | tqtc/lts-5.15 | pyside/tqtc-pyside-setup | Status: MERGED | +2 | 0 |
388408,4 | py3.10-prep: Fix a binary operator bug in cppgenerator.py | tqtc/lts-5.15 | pyside/tqtc-pyside-setup | Status: MERGED | +2 | 0 |
388429,4 | py3.10-prep: Fix a very old refcounting error in time_test.py | tqtc/lts-5.15 | pyside/tqtc-pyside-setup | Status: MERGED | +2 | 0 |
388526,4 | py3.10-prep: reset the type cache after feature switching | 5.15.2 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
388527,5 | py3.10-prep: Finally support Python 3.10 | 5.15.2 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
388528,5 | py3.10-prep: Fix a binary operator bug in cppgenerator.py | 5.15.2 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
388549,5 | py3.10-prep: Fix a very old refcounting error in time_test.py | 5.15.2 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
388551,5 | py3.10-prep: Fix parser.py for changed typing module | 5.15.2 | pyside/pyside-setup | Status: MERGED | +2 | 0 |
400200,4 | py3.10-prep: reset the type cache after feature switching | tqtc/lts-5.15.6 | pyside/tqtc-pyside-setup | Status: ABANDONED | 0 | 0 |
400201,4 | py3.10-prep: Finally support Python 3.10 | tqtc/lts-5.15.6 | pyside/tqtc-pyside-setup | Status: ABANDONED | 0 | 0 |
400202,4 | py3.10-prep: Fix a binary operator bug in cppgenerator.py | tqtc/lts-5.15.6 | pyside/tqtc-pyside-setup | Status: ABANDONED | 0 | 0 |
400203,4 | py3.10-prep: Fix a very old refcounting error in time_test.py | tqtc/lts-5.15.6 | pyside/tqtc-pyside-setup | Status: ABANDONED | 0 | 0 |
400205,4 | py3.10-prep: Fix parser.py for changed typing module | tqtc/lts-5.15.6 | pyside/tqtc-pyside-setup | Status: ABANDONED | 0 | 0 |