summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2023-01-19 23:34:11 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2023-01-19 23:34:11 +0900
commit1c362264d328c8886d33061ab992750741f7933a (patch)
treec56b482a6539c2992c97f3fe1bcb4d8ec46ef53f
parent6054548c2546819cb0413bf6438087f5fe8f4ab4 (diff)
downloadpytqt-1c362264.tar.gz
pytqt-1c362264.zip
Remove/replace old conditional python code.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r--sip/qt/qapplication.sip6
-rw-r--r--sip/qt/qbytearray.sip14
-rw-r--r--sip/qt/qcstring.sip8
-rw-r--r--sip/qt/qdir.sip4
-rw-r--r--sip/qt/qfile.sip4
-rw-r--r--sip/qt/qiodevice.sip16
-rw-r--r--sip/qt/qobject.sip50
-rw-r--r--sip/qt/qstring.sip32
-rw-r--r--sip/qt/qstringlist.sip12
-rw-r--r--sip/qt/qstrlist.sip2
-rw-r--r--sip/qtnetwork/qftp.sip2
-rw-r--r--sip/qtnetwork/qhttp.sip2
-rw-r--r--sip/qtnetwork/qsocket.sip4
-rw-r--r--sip/qtnetwork/qsocketdevice.sip2
14 files changed, 42 insertions, 116 deletions
diff --git a/sip/qt/qapplication.sip b/sip/qt/qapplication.sip
index d9247d9..28e0d67 100644
--- a/sip/qt/qapplication.sip
+++ b/sip/qt/qapplication.sip
@@ -210,7 +210,7 @@ public:
sipIsErr = 1;
else
for (int a = 0; a < argc; ++a)
- if (PyList_SetItem(sipRes,a,SIPBytes_FromString(sipCpp -> argv()[a])) < 0)
+ if (PyList_SetItem(sipRes,a,PyBytes_FromString(sipCpp -> argv()[a])) < 0)
{
Py_DECREF(sipRes);
sipIsErr = 1;
@@ -376,9 +376,9 @@ static char **pyArgvToC(PyObject *argvlist,int &argc)
{
arg = tqstrdup(sipString_AsUTF8String(&argObject));
}
- else if (SIPBytes_Check(argObject))
+ else if (PyBytes_Check(argObject))
{
- arg = tqstrdup(SIPBytes_AS_STRING(argObject));
+ arg = tqstrdup(PyBytes_AS_STRING(argObject));
}
else
{
diff --git a/sip/qt/qbytearray.sip b/sip/qt/qbytearray.sip
index d975472..f25ecd6 100644
--- a/sip/qt/qbytearray.sip
+++ b/sip/qt/qbytearray.sip
@@ -115,11 +115,7 @@ static PyObject* TQByteArray_To_String(TQByteArray *ba)
if (data)
{
-#if PY_MAJOR_VERSION >= 3
return PyUnicode_FromStringAndSize(data, len);
-#else
- return SIPBytes_FromStringAndSize(data, len);
-#endif
}
else
{
@@ -178,7 +174,7 @@ public:
if (res == Py_None)
{
- sipRes = SIPBytes_FromString("");
+ sipRes = PyBytes_FromString("");
}
else
{
@@ -191,7 +187,7 @@ public:
// Allow a Python string whenever a TQByteArray is expected.
if (sipIsErr == NULL)
- return (SIPBytes_Check(sipPy) ||
+ return (PyBytes_Check(sipPy) ||
PyUnicode_Check(sipPy) ||
sipCanConvertToInstance(sipPy,sipClass_TQByteArray,SIP_NO_CONVERTORS));
@@ -210,7 +206,6 @@ public:
return sipGetState(sipTransferObj);
}
-#if PY_VERSION_HEX >= 0x02060000
else if (PyByteArray_Check(sipPy))
{
Py_BEGIN_ALLOW_THREADS
@@ -223,13 +218,12 @@ public:
return sipGetState(sipTransferObj);
}
-#endif
- else if (SIPBytes_Check(sipPy))
+ else if (PyBytes_Check(sipPy))
{
Py_BEGIN_ALLOW_THREADS
TQByteArray *ba = new TQByteArray();
- ba -> duplicate(SIPBytes_AS_STRING(sipPy),SIPBytes_GET_SIZE(sipPy));
+ ba -> duplicate(PyBytes_AS_STRING(sipPy),PyBytes_GET_SIZE(sipPy));
*sipCppPtr = ba;
Py_END_ALLOW_THREADS
diff --git a/sip/qt/qcstring.sip b/sip/qt/qcstring.sip
index 099dab5..19387ae 100644
--- a/sip/qt/qcstring.sip
+++ b/sip/qt/qcstring.sip
@@ -193,19 +193,19 @@ public:
if (s == NULL)
s = "";
- sipRes = SIPBytes_FromString(s);
+ sipRes = PyBytes_FromString(s);
%End
%ConvertToTypeCode
// Allow a Python string whenever a TQCString is expected.
if (sipIsErr == NULL)
- return (SIPBytes_Check(sipPy) ||
+ return (PyBytes_Check(sipPy) ||
sipCanConvertToInstance(sipPy,sipClass_TQCString,SIP_NO_CONVERTORS));
- if (SIPBytes_Check(sipPy))
+ if (PyBytes_Check(sipPy))
{
- *sipCppPtr = new TQCString(SIPBytes_AS_STRING(sipPy));
+ *sipCppPtr = new TQCString(PyBytes_AS_STRING(sipPy));
return sipGetState(sipTransferObj);
}
diff --git a/sip/qt/qdir.sip b/sip/qt/qdir.sip
index 7048399..1d4c8db 100644
--- a/sip/qt/qdir.sip
+++ b/sip/qt/qdir.sip
@@ -215,11 +215,7 @@ public:
TQStringList operator[](SIP_PYSLICE) const;
%MethodCode
-#if PY_VERSION_HEX >= 0x02050000
Py_ssize_t len, start, stop, step, slicelength, i;
-#else
- int len, start, stop, step, slicelength, i;
-#endif
Py_BEGIN_ALLOW_THREADS
len = sipCpp -> count();
diff --git a/sip/qt/qfile.sip b/sip/qt/qfile.sip
index c89e824..5536c98 100644
--- a/sip/qt/qfile.sip
+++ b/sip/qt/qfile.sip
@@ -136,7 +136,7 @@ public:
Py_INCREF(Py_None);
sipRes = Py_None;
}
- else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
+ else if ((sipRes = PyBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1;
sipFree((void *)buf);
@@ -171,7 +171,7 @@ public:
}
else
{
- sipRes = SIPBytes_FromStringAndSize(buf,actlen);
+ sipRes = PyBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
diff --git a/sip/qt/qiodevice.sip b/sip/qt/qiodevice.sip
index 75ba7dc..30ca235 100644
--- a/sip/qt/qiodevice.sip
+++ b/sip/qt/qiodevice.sip
@@ -139,7 +139,7 @@ public:
}
else
{
- sipRes = SIPBytes_FromStringAndSize(buf,actlen);
+ sipRes = PyBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
@@ -159,15 +159,15 @@ public:
if (buf == Py_None)
sipRes = -1L;
- else if (!SIPBytes_Check(buf))
+ else if (!PyBytes_Check(buf))
{
sipBadCatcherResult(sipMethod);
sipIsErr = 1;
}
else
{
- memcpy(a0,SIPBytes_AS_STRING(buf),SIPBytes_GET_SIZE(buf));
- sipRes = SIPBytes_GET_SIZE(buf);
+ memcpy(a0,PyBytes_AS_STRING(buf),PyBytes_GET_SIZE(buf));
+ sipRes = PyBytes_GET_SIZE(buf);
}
Py_DECREF(buf);
@@ -201,7 +201,7 @@ public:
}
else
{
- sipRes = SIPBytes_FromStringAndSize(buf,actlen);
+ sipRes = PyBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
@@ -221,15 +221,15 @@ public:
if (buf == Py_None)
sipRes = -1L;
- else if (!SIPBytes_Check(buf))
+ else if (!PyBytes_Check(buf))
{
sipBadCatcherResult(sipMethod);
sipIsErr = 1;
}
else
{
- memcpy(a0,SIPBytes_AS_STRING(buf),SIPBytes_GET_SIZE(buf));
- sipRes = SIPBytes_GET_SIZE(buf);
+ memcpy(a0,PyBytes_AS_STRING(buf),PyBytes_GET_SIZE(buf));
+ sipRes = PyBytes_GET_SIZE(buf);
}
Py_DECREF(buf);
diff --git a/sip/qt/qobject.sip b/sip/qt/qobject.sip
index b6e0387..c0c30e5 100644
--- a/sip/qt/qobject.sip
+++ b/sip/qt/qobject.sip
@@ -337,11 +337,7 @@ public:
// the true (Python) class name.
SIP_PYOBJECT className() const;
%MethodCode
-#if PY_MAJOR_VERSION >= 3
sipRes = PyUnicode_FromString(sipSelf->ob_type->tp_name);
-#else
- sipRes = sipClassName(sipSelf);
-#endif
%End
// Note that tr() and trUtf8() are really static methods. We pretend
@@ -621,11 +617,11 @@ SIP_PYOBJECT SLOT(const char * /Encoding="ASCII"/) /TypeHint="QT_SLOT"/;
{
int len = strlen(a0);
- if ((sipRes = SIPBytes_FromStringAndSize(NULL,1 + len)) == NULL)
+ if ((sipRes = PyBytes_FromStringAndSize(NULL,1 + len)) == NULL)
sipIsErr = 1;
else
{
- char *dp = SIPBytes_AS_STRING(sipRes);
+ char *dp = PyBytes_AS_STRING(sipRes);
*dp++ = '1';
@@ -646,11 +642,11 @@ SIP_PYOBJECT SIGNAL(const char * /Encoding="ASCII"/) /TypeHint="QT_SIGNAL"/;
{
int len = strlen(a0);
- if ((sipRes = SIPBytes_FromStringAndSize(NULL,1 + len)) == NULL)
+ if ((sipRes = PyBytes_FromStringAndSize(NULL,1 + len)) == NULL)
sipIsErr = 1;
else
{
- char *dp = SIPBytes_AS_STRING(sipRes);
+ char *dp = PyBytes_AS_STRING(sipRes);
*dp++ = '2';
@@ -671,11 +667,11 @@ SIP_PYOBJECT PYSIGNAL(const char * /Encoding="ASCII"/);
{
int len = strlen(a0);
- if ((sipRes = SIPBytes_FromStringAndSize(NULL,1 + len)) == NULL)
+ if ((sipRes = PyBytes_FromStringAndSize(NULL,1 + len)) == NULL)
sipIsErr = 1;
else
{
- char *dp = SIPBytes_AS_STRING(sipRes);
+ char *dp = PyBytes_AS_STRING(sipRes);
*dp++ = '9';
@@ -736,12 +732,7 @@ extern "C" {
// The meta-type for PyTQt classes. It is just a marker type so that we can
// safely cast to get access to PyTQt3-specific data structures.
PyTypeObject pyqtWrapperType_Type = {
-#if PY_MAJOR_VERSION >= 3
PyVarObject_HEAD_INIT(NULL, 0)
-#else
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
-#endif
"qt.pyqtWrapperType", /* tp_name */
sizeof (sipWrapperType), /* tp_basicsize */
0, /* tp_itemsize */
@@ -755,10 +746,8 @@ PyTypeObject pyqtWrapperType_Type = {
0, /* tp_setattr */
#if PY_VERSION_HEX >= 0x03050000
0, /* tp_as_async */
-#elif PY_VERSION_HEX >= 0x03010000
- 0, /* tp_reserved */
#else
- 0, /* tp_compare */
+ 0, /* tp_reserved */
#endif
0, /* tp_repr */
0, /* tp_as_number */
@@ -797,16 +786,14 @@ PyTypeObject pyqtWrapperType_Type = {
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
-#if PY_VERSION_HEX >= 0x02060000
0, /* tp_version_tag */
-#endif
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#if PY_VERSION_HEX >= 0x03080000
0, /* tp_vectorcall */
#endif
-#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 8
+#if PY_VERSION_HEX == 0x03080000
0, /* tp_print (deprecated) */
#endif
};
@@ -963,12 +950,7 @@ static sipWrapperType pyqtWrapper_Type = {
{
#endif
{
-#if PY_MAJOR_VERSION >= 3
PyVarObject_HEAD_INIT(&pyqtWrapperType_Type, 0)
-#else
- PyObject_HEAD_INIT(&pyqtWrapperType_Type)
- 0, /* ob_size */
-#endif
"qt.pyqtWrapper", /* tp_name */
sizeof (pyqtWrapper), /* tp_basicsize */
0, /* tp_itemsize */
@@ -982,10 +964,8 @@ static sipWrapperType pyqtWrapper_Type = {
0, /* tp_setattr */
#if PY_VERSION_HEX >= 0x03050000
0, /* tp_as_async */
-#elif PY_VERSION_HEX >= 0x03010000
- 0, /* tp_reserved */
#else
- 0, /* tp_compare */
+ 0, /* tp_reserved */
#endif
0, /* tp_repr */
0, /* tp_as_number */
@@ -1024,16 +1004,14 @@ static sipWrapperType pyqtWrapper_Type = {
0, /* tp_subclasses */
0, /* tp_weaklist */
0, /* tp_del */
-#if PY_VERSION_HEX >= 0x02060000
0, /* tp_version_tag */
-#endif
#if PY_VERSION_HEX >= 0x03040000
0, /* tp_finalize */
#endif
#if PY_VERSION_HEX >= 0x03080000
0, /* tp_vectorcall */
#endif
-#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 8
+#if PY_VERSION_HEX == 0x03080000
0, /* tp_print (deprecated) */
#endif
},
@@ -1286,13 +1264,13 @@ bool UniversalSlot::tqt_invoke(int id, TQUObject *qargs)
case char_sat:
case schar_sat:
case uchar_sat:
- arg = SIPBytes_FromStringAndSize((char *)static_QUType_ptr.get(qargs), 1);
+ arg = PyBytes_FromStringAndSize((char *)static_QUType_ptr.get(qargs), 1);
break;
case string_sat:
case sstring_sat:
case ustring_sat:
- arg = SIPBytes_FromString((char *)static_QUType_ptr.get(qargs));
+ arg = PyBytes_FromString((char *)static_QUType_ptr.get(qargs));
break;
case short_sat:
@@ -2097,11 +2075,7 @@ PyObject *pyqt3GetSender()
Py_FatalError("qt: Failed to register pyqtWrapperType type");
// Initialise the super-type.
-#if PY_VERSION_HEX >= 0x02050000
pyqtWrapper_Type.super.ht_type.tp_base = sipWrapper_Type;
-#else
- pyqtWrapper_Type.super.type.tp_base = sipWrapper_Type;
-#endif
if (PyType_Ready((PyTypeObject *)&pyqtWrapper_Type) < 0)
Py_FatalError("qt: Failed to initialise pyqtWrapper type");
diff --git a/sip/qt/qstring.sip b/sip/qt/qstring.sip
index d06fec1..a09e68d 100644
--- a/sip/qt/qstring.sip
+++ b/sip/qt/qstring.sip
@@ -604,11 +604,7 @@ public:
TQString operator[](SIP_PYSLICE) const;
%MethodCode
-#if PY_VERSION_HEX >= 0x02050000
Py_ssize_t len, start, stop, step, slicelength, i;
-#else
- int len, start, stop, step, slicelength, i;
-#endif
len = sipCpp -> length();
@@ -651,7 +647,7 @@ public:
// expected.
if (sipIsErr == NULL)
- return (SIPBytes_Check(sipPy) ||
+ return (PyBytes_Check(sipPy) ||
PyUnicode_Check(sipPy) ||
sipCanConvertToInstance(sipPy,sipClass_TQString,SIP_NO_CONVERTORS));
@@ -717,7 +713,7 @@ public:
enc = codec->fromUnicode(*sipCpp);
- if ((encobj = SIPBytes_FromString(enc.data())) != NULL)
+ if ((encobj = PyBytes_FromString(enc.data())) != NULL)
{
*sipPtrPtr = (void *)PyString_AS_STRING(encobj);
sipRes = PyString_GET_SIZE(encobj);
@@ -870,14 +866,8 @@ TQString *PyTQt_qt_PyObject_AsTQString(PyObject *obj)
}
else if (PyBytes_Check(obj))
{
- return new TQString(SIPBytes_AS_STRING(obj));
- }
-#if PY_MAJOR_VERSION < 3
- else if (PyString_Check(obj))
- {
- return new TQString(PyString_AS_STRING(obj));
+ return new TQString(PyBytes_AS_STRING(obj));
}
-#endif
return NULL;
}
@@ -917,11 +907,7 @@ const char *PyTQt_qt_encode(PyObject **s, TQApplication::Encoding encoding)
TQByteArray ba = codec->fromUnicode(qs);
delete qstr;
-#if PY_MAJOR_VERSION >= 3
obj = PyBytes_FromStringAndSize(ba.data(), ba.size());
-#else
- obj = PyString_FromStringAndSize(ba.data(), ba.size());
-#endif
}
else
{
@@ -931,26 +917,14 @@ const char *PyTQt_qt_encode(PyObject **s, TQApplication::Encoding encoding)
if (obj)
{
-#if PY_MAJOR_VERSION >= 3
es = PyBytes_AS_STRING(obj);
-#else
- es = PyString_AS_STRING(obj);
-#endif
}
}
-#if PY_MAJOR_VERSION >= 3
else if (PyBytes_Check(obj))
{
es = PyBytes_AS_STRING(obj);
Py_INCREF(obj);
}
-#else
- else if (PyString_Check(obj))
- {
- es = PyString_AS_STRING(obj);
- Py_INCREF(obj);
- }
-#endif
else if (PyObject_AsCharBuffer(obj, &es, &sz) >= 0)
{
Py_INCREF(obj);
diff --git a/sip/qt/qstringlist.sip b/sip/qt/qstringlist.sip
index d7ece81..54e049d 100644
--- a/sip/qt/qstringlist.sip
+++ b/sip/qt/qstringlist.sip
@@ -105,11 +105,7 @@ public:
void __setitem__(SIP_PYSLICE,const TQStringList &);
%MethodCode
-#if PY_VERSION_HEX >= 0x02050000
Py_ssize_t len, start, stop, step, slicelength, i;
-#else
- int len, start, stop, step, slicelength, i;
-#endif
len = sipCpp -> count();
@@ -152,11 +148,7 @@ public:
void __delitem__(SIP_PYSLICE);
%MethodCode
-#if PY_VERSION_HEX >= 0x02050000
Py_ssize_t len, start, stop, step, slicelength, i;
-#else
- int len, start, stop, step, slicelength, i;
-#endif
len = sipCpp -> count();
@@ -184,11 +176,7 @@ public:
TQStringList operator[](SIP_PYSLICE slice);
%MethodCode
-#if PY_VERSION_HEX >= 0x02050000
Py_ssize_t len, start, stop, step, slicelength, i;
-#else
- int len, start, stop, step, slicelength, i;
-#endif
len = sipCpp -> count();
diff --git a/sip/qt/qstrlist.sip b/sip/qt/qstrlist.sip
index 2a35b65..40265a7 100644
--- a/sip/qt/qstrlist.sip
+++ b/sip/qt/qstrlist.sip
@@ -57,7 +57,7 @@ is used instead.
{
PyObject *ps;
- if ((ps = SIPBytes_FromString(s)) == NULL || PyList_SetItem(l,i,ps) < 0)
+ if ((ps = PyBytes_FromString(s)) == NULL || PyList_SetItem(l,i,ps) < 0)
{
Py_XDECREF(ps);
Py_DECREF(l);
diff --git a/sip/qtnetwork/qftp.sip b/sip/qtnetwork/qftp.sip
index 9edb2c4..ee945db 100644
--- a/sip/qtnetwork/qftp.sip
+++ b/sip/qtnetwork/qftp.sip
@@ -121,7 +121,7 @@ public:
Py_INCREF(Py_None);
sipRes = Py_None;
}
- else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
+ else if ((sipRes = PyBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1;
sipFree((void *)buf);
diff --git a/sip/qtnetwork/qhttp.sip b/sip/qtnetwork/qhttp.sip
index 9bb69b6..2f80e22 100644
--- a/sip/qtnetwork/qhttp.sip
+++ b/sip/qtnetwork/qhttp.sip
@@ -218,7 +218,7 @@ public:
Py_INCREF(Py_None);
sipRes = Py_None;
}
- else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
+ else if ((sipRes = PyBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1;
sipFree((void *)buf);
diff --git a/sip/qtnetwork/qsocket.sip b/sip/qtnetwork/qsocket.sip
index a31fa73..ed52819 100644
--- a/sip/qtnetwork/qsocket.sip
+++ b/sip/qtnetwork/qsocket.sip
@@ -164,7 +164,7 @@ public:
}
else
{
- sipRes = SIPBytes_FromStringAndSize(buf,actlen);
+ sipRes = PyBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
@@ -200,7 +200,7 @@ public:
}
else
{
- sipRes = SIPBytes_FromStringAndSize(buf,actlen);
+ sipRes = PyBytes_FromStringAndSize(buf,actlen);
sipFree((void *)buf);
diff --git a/sip/qtnetwork/qsocketdevice.sip b/sip/qtnetwork/qsocketdevice.sip
index 12d6b67..32ee5e5 100644
--- a/sip/qtnetwork/qsocketdevice.sip
+++ b/sip/qtnetwork/qsocketdevice.sip
@@ -123,7 +123,7 @@ public:
Py_INCREF(Py_None);
sipRes = Py_None;
}
- else if ((sipRes = SIPBytes_FromStringAndSize(buf,actlen)) == NULL)
+ else if ((sipRes = PyBytes_FromStringAndSize(buf,actlen)) == NULL)
sipIsErr = 1;
sipFree((void *)buf);