aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-10-27 17:09:45 +0100
committerChristian Tismer <tismer@stackless.com>2020-10-27 21:13:56 +0000
commit5de0db2391c719ef6c484813cc4aee61da355160 (patch)
tree93facde76f304de3118477d90163108e97018d09 /sources/pyside2
parentdcced0742f383b1932d0e56323387fbd8aeb4513 (diff)
remove traces of Python2 from C code
It will be assumed that Python is always Python 3. All checks for Python 2 are removed. This is the second part of cleaning up the C code from references to Python 2. Task-number: PYSIDE-904 Change-Id: I3006412c2a5bb65402101b0aac5a5f2fc79ce2f8 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside2')
-rw-r--r--sources/pyside2/PySide2/glue/qtcore.cpp34
-rw-r--r--sources/pyside2/libpyside/dynamicqmetaobject.cpp2
-rw-r--r--sources/pyside2/libpyside/pyside.cpp12
-rw-r--r--sources/pyside2/libpyside/pysideproperty.cpp7
-rw-r--r--sources/pyside2/libpyside/pysideqenum.cpp2
5 files changed, 4 insertions, 53 deletions
diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp
index 5d466b3f7..996d46d43 100644
--- a/sources/pyside2/PySide2/glue/qtcore.cpp
+++ b/sources/pyside2/PySide2/glue/qtcore.cpp
@@ -1038,40 +1038,11 @@ static int SbkQByteArray_getbufferproc(PyObject *obj, Py_buffer *view, int flags
#endif
}
-#if PY_VERSION_HEX < 0x03000000
-static Py_ssize_t SbkQByteArray_segcountproc(PyObject *self, Py_ssize_t *lenp)
-{
- if (lenp)
- *lenp = Py_TYPE(self)->tp_as_sequence->sq_length(self);
- return 1;
-}
-
-static Py_ssize_t SbkQByteArray_readbufferproc(PyObject *self, Py_ssize_t segment, void **ptrptr)
-{
- if (segment || !Shiboken::Object::isValid(self))
- return -1;
-
- QByteArray * cppSelf = %CONVERTTOCPP[QByteArray *](self);
- //XXX /|\ omitting this space crashes shiboken!
- *ptrptr = reinterpret_cast<void *>(cppSelf->data());
- return cppSelf->size();
-}
-
-PyBufferProcs SbkQByteArrayBufferProc = {
- /*bf_getreadbuffer*/ &SbkQByteArray_readbufferproc,
- /*bf_getwritebuffer*/ (writebufferproc) &SbkQByteArray_readbufferproc,
- /*bf_getsegcount*/ &SbkQByteArray_segcountproc,
- /*bf_getcharbuffer*/ (charbufferproc) &SbkQByteArray_readbufferproc,
- /*bf_getbuffer*/ (getbufferproc)SbkQByteArray_getbufferproc,
-};
-#else
-
static PyBufferProcs SbkQByteArrayBufferProc = {
/*bf_getbuffer*/ (getbufferproc)SbkQByteArray_getbufferproc,
/*bf_releasebuffer*/ (releasebufferproc)0,
};
-#endif
}
// @snippet qbytearray-bufferprotocol
@@ -1175,12 +1146,7 @@ if (PyBytes_Check(%PYARG_1)) {
// @snippet qbytearray-3
// @snippet qbytearray-py3
-#if PY_VERSION_HEX < 0x03000000
-Shiboken::SbkType<QByteArray>()->tp_as_buffer = &SbkQByteArrayBufferProc;
-Shiboken::SbkType<QByteArray>()->tp_flags |= Py_TPFLAGS_HAVE_NEWBUFFER;
-#else
PepType_AS_BUFFER(Shiboken::SbkType<QByteArray>()) = &SbkQByteArrayBufferProc;
-#endif
// @snippet qbytearray-py3
// @snippet qbytearray-data
diff --git a/sources/pyside2/libpyside/dynamicqmetaobject.cpp b/sources/pyside2/libpyside/dynamicqmetaobject.cpp
index 2fbda3f6a..f67e97e01 100644
--- a/sources/pyside2/libpyside/dynamicqmetaobject.cpp
+++ b/sources/pyside2/libpyside/dynamicqmetaobject.cpp
@@ -569,7 +569,7 @@ void MetaObjectBuilderPrivate::parsePythonType(PyTypeObject *type)
// Therefore, we don't need to error-check here again.
auto name = String::toCString(obName);
AutoDecRef members(PyObject_GetAttr(obEnumType, PyMagicName::members()));
- AutoDecRef items(PepMapping_Items(members));
+ AutoDecRef items(PyMapping_Items(members));
Py_ssize_t nr_items = PySequence_Length(items);
QVector<QPair<QByteArray, int> > entries;
diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp
index 2404788d3..4995f35dd 100644
--- a/sources/pyside2/libpyside/pyside.cpp
+++ b/sources/pyside2/libpyside/pyside.cpp
@@ -533,17 +533,7 @@ bool registerInternalQtConf()
// This will disable the internal qt.conf which points to the PySide2 subdirectory (due to the
// subdirectory not existing anymore).
QString executablePath =
-#if PY_MAJOR_VERSION >= 3
- QString::fromWCharArray(Py_GetProgramFullPath());
-#else
- // Python 2 unfortunately returns a char * array instead of a wchar *, which means that on
- // Windows if the executable path contains unicode characters, the returned path will be
- // invalid. We can't use QCoreApplication::applicationFilePath because it requires an
- // existing QCoreApplication instance despite being a static method.
- // This means that a qt.conf near an executable won't be picked up correctly on
- // Windows + Python 2.
- QString::fromLocal8Bit(Py_GetProgramFullPath());
-#endif
+ QString::fromWCharArray(Py_GetProgramFullPath());
QString appDirPath = QFileInfo(executablePath).absolutePath();
QString maybeQtConfPath = QDir(appDirPath).filePath(QStringLiteral("qt.conf"));
bool executableQtConfAvailable = QFileInfo::exists(maybeQtConfPath);
diff --git a/sources/pyside2/libpyside/pysideproperty.cpp b/sources/pyside2/libpyside/pysideproperty.cpp
index bcb2ab356..30cfabf86 100644
--- a/sources/pyside2/libpyside/pysideproperty.cpp
+++ b/sources/pyside2/libpyside/pysideproperty.cpp
@@ -354,13 +354,8 @@ static PyObject *qPropertyDocGet(PyObject *self, void *)
PySidePropertyPrivate *pData = data->d;
QByteArray doc(pData->doc);
- if (!doc.isEmpty()) {
-#if PY_MAJOR_VERSION >= 3
+ if (!doc.isEmpty())
return PyUnicode_FromString(doc);
-#else
- return PyString_FromString(doc);
-#endif
- }
if (pData->fget != nullptr) {
// PYSIDE-1019: Fetch the default `__doc__` from fget. We do it late.
AutoDecRef get_doc(PyObject_GetAttr(pData->fget, PyMagicName::doc()));
diff --git a/sources/pyside2/libpyside/pysideqenum.cpp b/sources/pyside2/libpyside/pysideqenum.cpp
index f46b5536c..07a548cb6 100644
--- a/sources/pyside2/libpyside/pysideqenum.cpp
+++ b/sources/pyside2/libpyside/pysideqenum.cpp
@@ -66,7 +66,7 @@ static PyObject *analyzePyEnum(PyObject *pyenum, PyObject *container = nullptr)
AutoDecRef members(PyObject_GetAttr(pyenum, Shiboken::PyMagicName::members()));
if (members.isNull())
return nullptr;
- AutoDecRef items(PepMapping_Items(members));
+ AutoDecRef items(PyMapping_Items(members));
if (items.isNull())
return nullptr;
int iflag = PySide::QEnum::isFlag(pyenum);