aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/libshiboken/signature/signature.cpp
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2022-03-13 19:22:02 +0100
committerChristian Tismer <tismer@stackless.com>2022-03-15 16:12:58 +0100
commitb702a05c2f2a48be5ef77cdc8e8f4cc4cdb2e9c1 (patch)
tree81fecf74611015fa7bab113b9368d6457885bb8f /sources/shiboken6/libshiboken/signature/signature.cpp
parent38fe8062b6f03dae438dc4e42537c131a98eceb0 (diff)
PyPySide: handle signature with the new "builtin method" type
PyPy never had a distinction between normal methods and builtin methods like Python has by PyCFunction. Not immediately on our demand, but because the NumPy extension grew a problem out of exactly the same fact, a new "builtin method" was created. Using this new type, three errors concerning signatures could be resolved: sample::renaming QtWidgets::signature_test QtQml::qqmlnetwork_test [ChangeLog][PySide6] The new PyPy "builtin method" is now adopted and handled correctly in the signature module. Task-number: PYSIDE-1843 Task-number: PYSIDE-535 Change-Id: I462fe67fe63453fc214e332645dba60a1d399f5c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken6/libshiboken/signature/signature.cpp')
-rw-r--r--sources/shiboken6/libshiboken/signature/signature.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/sources/shiboken6/libshiboken/signature/signature.cpp b/sources/shiboken6/libshiboken/signature/signature.cpp
index b7becca26..ab33becac 100644
--- a/sources/shiboken6/libshiboken/signature/signature.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature.cpp
@@ -86,6 +86,11 @@ PyObject *GetClassOrModOf(PyObject *ob)
Py_INCREF(ob);
return ob;
}
+#ifdef PYPY_VERSION
+ // PYSIDE-535: PyPy has a special builtin method that acts almost like PyCFunction.
+ if (Py_TYPE(ob) == PepBuiltinMethod_TypePtr)
+ return _get_class_of_bm(ob);
+#endif
if (PyType_IsSubtype(Py_TYPE(ob), &PyCFunction_Type))
return _get_class_of_cf(ob);
if (Py_TYPE(ob) == PepStaticMethod_TypePtr)
@@ -167,6 +172,24 @@ static PyObject *_GetSignature_Cached(PyObject *props, PyObject *func_kind, PyOb
return Py_INCREF(value), value;
}
+#ifdef PYPY_VERSION
+PyObject *GetSignature_Method(PyObject *obfunc, PyObject *modifier)
+{
+ AutoDecRef obtype_mod(GetClassOrModOf(obfunc));
+ AutoDecRef type_key(GetTypeKey(obtype_mod));
+ if (type_key.isNull())
+ Py_RETURN_NONE;
+ PyObject *dict = TypeKey_to_PropsDict(type_key, obtype_mod);
+ if (dict == nullptr)
+ return nullptr;
+ AutoDecRef func_name(PyObject_GetAttr(obfunc, PyMagicName::name()));
+ PyObject *props = !func_name.isNull() ? PyDict_GetItem(dict, func_name) : nullptr;
+ if (props == nullptr)
+ Py_RETURN_NONE;
+ return _GetSignature_Cached(props, PyName::method(), modifier);
+}
+#endif
+
PyObject *GetSignature_Function(PyObject *obfunc, PyObject *modifier)
{
// make sure that we look into PyCFunction, only...
@@ -243,6 +266,12 @@ PyObject *GetSignature_TypeMod(PyObject *ob, PyObject *modifier)
PyObject *get_signature_intern(PyObject *ob, PyObject *modifier)
{
+#ifdef PYPY_VERSION
+ // PYSIDE-535: PyPy has a special builtin method that acts almost like PyCFunction.
+ if (Py_TYPE(ob) == PepBuiltinMethod_TypePtr) {
+ return pyside_bm_get___signature__(ob, modifier);
+ }
+#endif
if (PyType_IsSubtype(Py_TYPE(ob), &PyCFunction_Type))
return pyside_cf_get___signature__(ob, modifier);
if (Py_TYPE(ob) == PepStaticMethod_TypePtr)