aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-11-02 15:52:02 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-11-11 13:39:22 +0000
commit3dafa8c987bbc528ad2990b3fe3554b05d7e87b9 (patch)
treedd0a2e1d068d94306c4b28e9e2db71e8a381e7f3 /sources
parent6a2e912deadc4b1ddbc18ba390822bcdb1724041 (diff)
PyPySide: Replace type patching by heaptype, 1(5)
PyPy does not allow patching of non-heaptypes. We did that trick for simplicity in the signature module where we created a `__signature__` attribute for types. This patch removes the type modification and uses our heaptypes, only. For other types, more work is needed. It also fixes the metatype for enums which was wrong. This is the first replacement of o PyType_Type * PyMethodDescr_Type * PyCFunction_Type * PyStaticMethod_Type * PyWrapperDescr_Type The patches will be replaced by heaptypes if possible, or we might use signatures in a shadow dict, instead. [ChangeLog][shiboken6] Remove type patching of PyType_Type and fix the meta type of enum. Task-number: PYSIDE-535 Change-Id: I221834661709c71ee9ed17b3d6cc293b87447ab7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 9c7d7a5d19b4a1f57d67694f03a90ddd3b3ff4a9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken6/libshiboken/sbkenum.cpp9
-rw-r--r--sources/shiboken6/libshiboken/signature/signature_extend.cpp9
2 files changed, 12 insertions, 6 deletions
diff --git a/sources/shiboken6/libshiboken/sbkenum.cpp b/sources/shiboken6/libshiboken/sbkenum.cpp
index dbf338331..dbea84fb8 100644
--- a/sources/shiboken6/libshiboken/sbkenum.cpp
+++ b/sources/shiboken6/libshiboken/sbkenum.cpp
@@ -264,12 +264,19 @@ static PyGetSetDef SbkEnumGetSetList[] = {
static void SbkEnumTypeDealloc(PyObject *pyObj);
static PyObject *SbkEnumTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *kwds);
+static PyGetSetDef SbkEnumType_getsetlist[] = {
+ {const_cast<char *>("__signature__"), reinterpret_cast<getter>(Sbk_TypeGet___signature__),
+ nullptr, nullptr, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr} // Sentinel
+};
+
static PyType_Slot SbkEnumType_Type_slots[] = {
{Py_tp_dealloc, reinterpret_cast<void *>(SbkEnumTypeDealloc)},
{Py_tp_base, reinterpret_cast<void *>(&PyType_Type)},
{Py_tp_alloc, reinterpret_cast<void *>(PyType_GenericAlloc)},
{Py_tp_new, reinterpret_cast<void *>(SbkEnumTypeTpNew)},
{Py_tp_free, reinterpret_cast<void *>(PyObject_GC_Del)},
+ {Py_tp_getset, reinterpret_cast<void *>(SbkEnumType_getsetlist)},
{0, nullptr}
};
static PyType_Spec SbkEnumType_Type_spec = {
@@ -614,7 +621,7 @@ static PyType_Spec SbkNewEnum_spec = {
static PyTypeObject *SbkEnum_TypeF()
{
- static auto type = SbkType_FromSpec(&SbkNewEnum_spec);
+ static auto type = SbkType_FromSpecWithMeta(&SbkNewEnum_spec, SbkEnumType_TypeF());
return type;
}
diff --git a/sources/shiboken6/libshiboken/signature/signature_extend.cpp b/sources/shiboken6/libshiboken/signature/signature_extend.cpp
index 528c7c87a..4b67d778f 100644
--- a/sources/shiboken6/libshiboken/signature/signature_extend.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature_extend.cpp
@@ -48,12 +48,14 @@
// PyMethodDescr_Type
// PyCFunction_Type
// PyStaticMethod_Type
-// PyType_Type
+// (*) PyType_Type
// PyWrapperDescr_Type
//
-// Their `tp_getset` fields are modified so support the `__signature__`
+// Their `tp_getset` fields are modified to support the `__signature__`
// attribute and additions to the `__doc__` attribute.
//
+// PYSIDE-535: PyType_Type patching is removed,
+// Shiboken.ObjectType and Shiboken.EnumMeta have new getsets, instead.
#include "autodecref.h"
#include "sbkstring.h"
@@ -282,8 +284,6 @@ int PySide_PatchTypes(void)
auto cf_doc = &old_cf_doc_descr;
auto sm_gs = new_PyStaticMethod_getsets;
auto sm_doc = &old_sm_doc_descr;
- auto tp_gs = new_PyType_getsets;
- auto tp_doc = &old_tp_doc_descr;
auto wd_gs = new_PyWrapperDescr_getsets;
auto wd_doc = &old_wd_doc_descr;
@@ -292,7 +292,6 @@ int PySide_PatchTypes(void)
|| add_more_getsets(PepMethodDescr_TypePtr, md_gs, md_doc) < 0
|| add_more_getsets(&PyCFunction_Type, cf_gs, cf_doc) < 0
|| add_more_getsets(PepStaticMethod_TypePtr, sm_gs, sm_doc) < 0
- || add_more_getsets(&PyType_Type, tp_gs, tp_doc) < 0
|| add_more_getsets(Py_TYPE(wrap_descr), wd_gs, wd_doc) < 0
)
return -1;