aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sources/shiboken6/libshiboken/basewrapper.cpp6
-rw-r--r--sources/shiboken6/libshiboken/sbkenum.cpp6
2 files changed, 10 insertions, 2 deletions
diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp
index 90cb16ef5..fa60455db 100644
--- a/sources/shiboken6/libshiboken/basewrapper.cpp
+++ b/sources/shiboken6/libshiboken/basewrapper.cpp
@@ -152,10 +152,14 @@ static PyType_Slot SbkObjectType_Type_slots[] = {
{Py_tp_getset, reinterpret_cast<void *>(SbkObjectType_Type_getsetlist)},
{0, nullptr}
};
+
+// PYSIDE-535: The tp_itemsize field is inherited and does not need to be set.
+// In PyPy, it _must_ not be set, because it would have the meaning that a
+// `__len__` field must be defined. Not doing so creates a hard-to-find crash.
static PyType_Spec SbkObjectType_Type_spec = {
"1:Shiboken.ObjectType",
0,
- sizeof(PyMemberDef),
+ 0, // sizeof(PyMemberDef), not for PyPy without a __len__ defined
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
SbkObjectType_Type_slots,
};
diff --git a/sources/shiboken6/libshiboken/sbkenum.cpp b/sources/shiboken6/libshiboken/sbkenum.cpp
index 52a177ed3..cad31aab1 100644
--- a/sources/shiboken6/libshiboken/sbkenum.cpp
+++ b/sources/shiboken6/libshiboken/sbkenum.cpp
@@ -272,10 +272,14 @@ static PyType_Slot SbkEnumType_Type_slots[] = {
{Py_tp_free, reinterpret_cast<void *>(PyObject_GC_Del)},
{0, nullptr}
};
+
+// PYSIDE-535: The tp_itemsize field is inherited and does not need to be set.
+// In PyPy, it _must_ not be set, because it would have the meaning that a
+// `__len__` field must be defined. Not doing so creates a hard-to-find crash.
static PyType_Spec SbkEnumType_Type_spec = {
"1:Shiboken.EnumMeta",
0,
- sizeof(PyMemberDef),
+ 0, // sizeof(PyMemberDef), not for PyPy without a __len__ defined
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
SbkEnumType_Type_slots,
};