diff options
author | Christian Tismer <tismer@stackless.com> | 2022-02-27 13:36:53 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-02-28 15:55:11 +0000 |
commit | ab7e0fea1e64f4c56073a798bab2068eb6b04722 (patch) | |
tree | 86375ce495ce19bbaa840fdff49f6246cf6cd89a | |
parent | 5587b62fb81a95ad2fd74c6d1beb396b3503a966 (diff) |
PyPySide: Fix a regression with thread initialization
The mandelbrot.py example worked fine on macOS, but failed
to run on Windows and Linux.
This did not show up on my local Windows virtual machine
after building. But cloning the machine and removing the
developer partition revealed the same issue on the clone.
It turned out that PyPy needed a PyEval_InitThreads call.
This call is already deprecated and a no-op on Python 3.9.
Adding this call fixed the problem.
We need to contact the PyPy group because they have a
PyPython 3.9 beta, which is dependent from a deprecated function.
[ChangeLog][PySide6] Threading stability was much improved
by a call to PyEval_InitThreads (deprecated in Python 3.9).
Task-number: PYSIDE-535
Change-Id: Ibf6d92bf0b21542be8929e12a6e02389c036ec79
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit c6f280a074391627d173e0fc27c104a2db667936)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/pyside6/PySide6/QtCore/typesystem_core_common.xml | 3 | ||||
-rw-r--r-- | sources/pyside6/PySide6/glue/qtcore.cpp | 11 |
2 files changed, 13 insertions, 1 deletions
diff --git a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml index 3683b2543..96c053079 100644 --- a/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml +++ b/sources/pyside6/PySide6/QtCore/typesystem_core_common.xml @@ -1521,6 +1521,9 @@ <modify-argument index="1"> <rename to="priority"/> </modify-argument> + <!-- PYSIDE-535: PyPy 7.3.8 needs this call, which is actually a no-op in Python 3.10 --> + <inject-code file="../glue/qtcore.cpp" class="target" position="beginning" + snippet="qthread_init_pypy"/> </modify-function> <modify-function signature="exit(int)" allow-thread="yes"/> </object-type> diff --git a/sources/pyside6/PySide6/glue/qtcore.cpp b/sources/pyside6/PySide6/glue/qtcore.cpp index 218b2d698..37e5f3c9c 100644 --- a/sources/pyside6/PySide6/glue/qtcore.cpp +++ b/sources/pyside6/PySide6/glue/qtcore.cpp @@ -1588,7 +1588,16 @@ Py_END_ALLOW_THREADS } } // @snippet qt-module-shutdown -// + +// @snippet qthread_init_pypy +#ifdef PYPY_VERSION +// PYSIDE-535: PyPy 7.3.8 needs this call, which is actually a no-op in Python 3.9 +// This function should be replaced by a `Py_Initialize` call, but +// that is still undefined. So we don't rely yet on any PyPy version. +PyEval_InitThreads(); +#endif +// @snippet qthread_init_pypy + // @snippet qthread_exec_ if (PyErr_WarnEx(PyExc_DeprecationWarning, "'exec_' will be removed in the future. " |