db-move: moved polari from [testing] to [extra] (x86_64)
[arch-packages.git] / pyside2 / trunk / python3.11.patch
blob311a240a2e53f3499a33ec52d1301bf4981ced2f
1 From b64ad27d8dfeeecaaa8a98051252a32c9d998df4 Mon Sep 17 00:00:00 2001
2 From: Friedemann Kleint <Friedemann.Kleint@qt.io>
3 Date: Thu, 9 Jun 2022 16:50:41 +0200
4 Subject: [PATCH] libshiboken: Fix a crash in Shiboken::Object::isValid() for
5 Python 3.11
7 The function is passed type objects for class methods, which caused
8 it to crash.
10 The first clause did not catch this, and so it was cast to SbkObject
11 below.
13 Add a type check to prevent this.
15 Pick-to: 6.3 6.2 5.15
16 Task-number: PYSIDE-1960
17 Change-Id: Icfdd6fefb7156ac5961444bd5395109849a1d66e
18 Reviewed-by: Christian Tismer <tismer@stackless.com>
19 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
20 ---
21 sources/shiboken2/libshiboken/basewrapper.cpp | 1 +
22 1 file changed, 1 insertion(+)
24 Index: pyside-setup-opensource-src-5.15.7/sources/shiboken2/libshiboken/basewrapper.cpp
25 ===================================================================
26 --- pyside-setup-opensource-src-5.15.7.orig/sources/shiboken2/libshiboken/basewrapper.cpp
27 +++ pyside-setup-opensource-src-5.15.7/sources/shiboken2/libshiboken/basewrapper.cpp
28 @@ -377,7 +377,7 @@ SbkObjectType *SbkObject_TypeF(void)
29 static PyTypeObject *type = nullptr;
30 if (!type) {
31 type = reinterpret_cast<PyTypeObject *>(SbkType_FromSpec(&SbkObject_Type_spec));
32 - Py_TYPE(type) = SbkObjectType_TypeF();
33 + Py_SET_TYPE(type, SbkObjectType_TypeF());
34 Py_INCREF(Py_TYPE(type));
35 type->tp_weaklistoffset = offsetof(SbkObject, weakreflist);
36 type->tp_dictoffset = offsetof(SbkObject, ob_dict);
37 @@ -1160,7 +1160,7 @@ introduceWrapperType(PyObject *enclosing
38 typeSpec->slots[0].pfunc = reinterpret_cast<void *>(baseType ? baseType : SbkObject_TypeF());
40 PyObject *heaptype = SbkType_FromSpecWithBases(typeSpec, baseTypes);
41 - Py_TYPE(heaptype) = SbkObjectType_TypeF();
42 + Py_SET_TYPE(heaptype, SbkObjectType_TypeF());
43 Py_INCREF(Py_TYPE(heaptype));
44 auto *type = reinterpret_cast<SbkObjectType *>(heaptype);
45 #if PY_VERSION_HEX < 0x03000000
46 @@ -1525,6 +1525,7 @@ bool setCppPointer(SbkObject *sbkObj, Py
47 bool isValid(PyObject *pyObj)
49 if (!pyObj || pyObj == Py_None
50 + || PyType_Check(pyObj) != 0
51 || Py_TYPE(Py_TYPE(pyObj)) != SbkObjectType_TypeF()) {
52 return true;
54 Index: pyside-setup-opensource-src-5.15.7/sources/pyside2/libpyside/pysideqflags.cpp
55 ===================================================================
56 --- pyside-setup-opensource-src-5.15.7.orig/sources/pyside2/libpyside/pysideqflags.cpp
57 +++ pyside-setup-opensource-src-5.15.7/sources/pyside2/libpyside/pysideqflags.cpp
58 @@ -192,7 +192,7 @@ namespace QFlags
60 newspec.slots = SbkNewQFlagsType_spec.slots;
61 PyTypeObject *type = (PyTypeObject *)SbkType_FromSpec(&newspec);
62 - Py_TYPE(type) = &PyType_Type;
63 + Py_SET_TYPE(type, &PyType_Type);
65 PySideQFlagsType *flagsType = reinterpret_cast<PySideQFlagsType *>(type);
66 PepType_PFTP(flagsType)->converterPtr = &PepType_PFTP(flagsType)->converter;
67 Index: pyside-setup-opensource-src-5.15.7/sources/pyside2/libpyside/pysidesignal.cpp
68 ===================================================================
69 --- pyside-setup-opensource-src-5.15.7.orig/sources/pyside2/libpyside/pysidesignal.cpp
70 +++ pyside-setup-opensource-src-5.15.7/sources/pyside2/libpyside/pysidesignal.cpp
71 @@ -162,7 +162,7 @@ PyTypeObject *PySideSignalTypeF(void)
72 if (!type) {
73 type = reinterpret_cast<PyTypeObject *>(SbkType_FromSpec(&PySideSignalType_spec));
74 PyTypeObject *hold = Py_TYPE(type);
75 - Py_TYPE(type) = PySideMetaSignalTypeF();
76 + Py_SET_TYPE(type, PySideMetaSignalTypeF());
77 Py_INCREF(Py_TYPE(type));
78 Py_DECREF(hold);
80 Index: pyside-setup-opensource-src-5.15.7/sources/pyside2/libpyside/pysideweakref.cpp
81 ===================================================================
82 --- pyside-setup-opensource-src-5.15.7.orig/sources/pyside2/libpyside/pysideweakref.cpp
83 +++ pyside-setup-opensource-src-5.15.7/sources/pyside2/libpyside/pysideweakref.cpp
84 @@ -90,7 +90,7 @@ PyObject *create(PyObject *obj, PySideWe
86 if (Py_TYPE(PySideCallableObjectTypeF()) == 0)
88 - Py_TYPE(PySideCallableObjectTypeF()) = &PyType_Type;
89 + Py_SET_TYPE(PySideCallableObjectTypeF(), &PyType_Type);
90 PyType_Ready(PySideCallableObjectTypeF());
93 Index: pyside-setup-opensource-src-5.15.7/sources/shiboken2/libshiboken/sbkenum.cpp
94 ===================================================================
95 --- pyside-setup-opensource-src-5.15.7.orig/sources/shiboken2/libshiboken/sbkenum.cpp
96 +++ pyside-setup-opensource-src-5.15.7/sources/shiboken2/libshiboken/sbkenum.cpp
97 @@ -754,7 +754,7 @@ newTypeWithName(const char *name,
98 PyTuple_SetItem(bases, 0, reinterpret_cast<PyObject *>(basetype));
99 auto *type = reinterpret_cast<PyTypeObject *>(SbkType_FromSpecWithBases(&newspec, bases));
100 PyErr_Print();
101 - Py_TYPE(type) = SbkEnumType_TypeF();
102 + Py_SET_TYPE(type, SbkEnumType_TypeF());
104 auto *enumType = reinterpret_cast<SbkEnumType *>(type);
105 PepType_SETP(enumType)->cppName = cppName;
106 Index: pyside-setup-opensource-src-5.15.7/sources/shiboken2/libshiboken/sbkstring.cpp
107 ===================================================================
108 --- pyside-setup-opensource-src-5.15.7.orig/sources/shiboken2/libshiboken/sbkstring.cpp
109 +++ pyside-setup-opensource-src-5.15.7/sources/shiboken2/libshiboken/sbkstring.cpp
110 @@ -41,8 +41,14 @@
111 #include "sbkstaticstrings_p.h"
112 #include "autodecref.h"
114 -#include <vector>
115 -#include <unordered_set>
116 +#if PY_VERSION_HEX >= 0x030B0000 || defined(Py_LIMITED_API)
117 +# define USE_INTERN_STRINGS
118 +#endif
120 +#ifndef USE_INTERN_STRINGS
121 +# include <vector>
122 +# include <unordered_set>
123 +#endif
125 namespace Shiboken
127 @@ -233,6 +239,13 @@ Py_ssize_t len(PyObject *str)
128 // PyObject *attr = PyObject_GetAttr(obj, name());
131 +#ifdef USE_INTERN_STRINGS
132 +PyObject *createStaticString(const char *str)
134 + return PyUnicode_InternFromString(str);
136 +#else
138 using StaticStrings = std::unordered_set<PyObject *>;
140 static void finalizeStaticStrings(); // forward
141 @@ -283,6 +296,8 @@ PyObject *createStaticString(const char
142 return result;
145 +#endif // !USE_INTERN_STRINGS
147 ///////////////////////////////////////////////////////////////////////
149 // PYSIDE-1019: Helper function for snake_case vs. camelCase names
150 Index: pyside-setup-opensource-src-5.15.7/build_scripts/config.py
151 ===================================================================
152 --- pyside-setup-opensource-src-5.15.7.orig/build_scripts/config.py
153 +++ pyside-setup-opensource-src-5.15.7/build_scripts/config.py
154 @@ -94,6 +94,7 @@ class Config(object):
155 'Programming Language :: Python :: 3.8',
156 'Programming Language :: Python :: 3.9',
157 'Programming Language :: Python :: 3.10',
158 + 'Programming Language :: Python :: 3.11',
161 self.setup_script_dir = None