aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2023-03-23 14:45:39 +0100
committerChristian Tismer <tismer@stackless.com>2023-03-23 15:36:49 +0100
commit3b91e4a7886c8ca286bd50cbf638de15ff386919 (patch)
tree8f271bc1568f2b3c052a2034150a72b4e7150e46
parentae47e8fa7e6b7c7abf7257936cb208e8b5034b6a (diff)
PyPySide: Fix a crash with PyPy 7.3.10 and 7.3.11
The PyPy installation had no problems with the built-in _functools module, which we still use in favor of the official functools module, which is slower and can be manipulated. The _functools module is no longer found in PyPy, and speed issues do not apply. [ChangeLog][shiboken6] A PyPy problem with version 7.3.10 and up was fixed. Change-Id: Ie064d803d3fbf0f4ca226329b4d317db2a44c045 Fixes: PYSIDE-2264 Task-number: PYSIDE-535 Pick-to: 6.5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/shiboken6/libshiboken/sbkenum.cpp7
-rw-r--r--sources/shiboken6/libshiboken/sbkfeature_base.cpp7
2 files changed, 12 insertions, 2 deletions
diff --git a/sources/shiboken6/libshiboken/sbkenum.cpp b/sources/shiboken6/libshiboken/sbkenum.cpp
index 9b416886f..fb70a1c8f 100644
--- a/sources/shiboken6/libshiboken/sbkenum.cpp
+++ b/sources/shiboken6/libshiboken/sbkenum.cpp
@@ -1065,11 +1065,16 @@ static PyObject *create_missing_func(PyObject *klass)
{
// When creating the class, memorize it in the missing function by
// a partial function argument.
+#ifdef PYPY_VERSION
+ const char *functools_str = "functools";
+#else
+ const char *functools_str = "_functools";
+#endif
static auto *const type = SbkType_FromSpec(&dummy_spec);
static auto *const obType = reinterpret_cast<PyObject *>(type);
static auto *const _missing = Shiboken::String::createStaticString("_missing_");
static auto *const func = PyObject_GetAttr(obType, _missing);
- static auto *const functools = PyImport_ImportModule("_functools"); // builtin
+ static auto *const functools = PyImport_ImportModule(functools_str); // builtin
static auto *const _partial = Shiboken::String::createStaticString("partial");
static auto *const partial = PyObject_GetAttr(functools, _partial);
return PyObject_CallFunctionObjArgs(partial, func, klass, nullptr);
diff --git a/sources/shiboken6/libshiboken/sbkfeature_base.cpp b/sources/shiboken6/libshiboken/sbkfeature_base.cpp
index 63b5d9e57..d732faa29 100644
--- a/sources/shiboken6/libshiboken/sbkfeature_base.cpp
+++ b/sources/shiboken6/libshiboken/sbkfeature_base.cpp
@@ -178,7 +178,12 @@ void initEnumFlagsDict(PyTypeObject *type)
static PyObject *replaceNoArgWithZero(PyObject *callable)
{
- static auto *functools = PyImport_ImportModule("_functools"); // builtin
+#ifdef PYPY_VERSION
+ const char *functools_str = "functools";
+#else
+ const char *functools_str = "_functools";
+#endif
+ static auto *functools = PyImport_ImportModule(functools_str); // builtin
static auto *partial = PyObject_GetAttrString(functools, "partial");
static auto *zero = PyLong_FromLong(0);
return PyObject_CallFunctionObjArgs(partial, callable, zero, nullptr);