Skip to content

Commit 36bb187

Browse files
jcfrmrbean-bremen
authored andcommitted
chore(PythonQt): replace PyString_Check with PyUnicode_Check
Update assertions and type checks to the Unicode API. No functional change intended.
1 parent 40fce21 commit 36bb187

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/PythonQt.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ QString PythonQt::getReturnTypeOfWrappedMethodHelper(const PythonQtObjectPtr& va
19771977
PythonQtClassInfo* typeInfo = _p->_knownClassInfos.value(QStringToPythonConstCharPointer(type));
19781978
if (typeInfo && typeInfo->pythonQtClassWrapper()) {
19791979
PyObject* s = PyObject_GetAttrString(typeInfo->pythonQtClassWrapper(), "__module__");
1980-
Q_ASSERT(PyString_Check(s));
1980+
Q_ASSERT(PyUnicode_Check(s));
19811981
type = QString(PyUnicode_AsUTF8(s)) + "." + type;
19821982
Py_DECREF(s);
19831983
}
@@ -2480,7 +2480,7 @@ QString PythonQtPrivate::getSignature(PyObject* object)
24802480

24812481
PyObject* s = PyObject_GetAttrString(object, "__name__");
24822482
if (s) {
2483-
Q_ASSERT(PyString_Check(s));
2483+
Q_ASSERT(PyUnicode_Check(s));
24842484
signature = PyUnicode_AsUTF8(s);
24852485
if (docstr.startsWith(signature + "(")) {
24862486
signature = docstr;
@@ -2499,14 +2499,14 @@ QString PythonQtPrivate::getSignature(PyObject* object)
24992499
QString funcName;
25002500
PyObject* s = PyObject_GetAttrString((PyObject*)func, "__name__");
25012501
if (s) {
2502-
Q_ASSERT(PyString_Check(s));
2502+
Q_ASSERT(PyUnicode_Check(s));
25032503
funcName = PyUnicode_AsUTF8(s);
25042504
Py_DECREF(s);
25052505
}
25062506
if (method && funcName == "__init__") {
25072507
PyObject* s = PyObject_GetAttrString(object, "__name__");
25082508
if (s) {
2509-
Q_ASSERT(PyString_Check(s));
2509+
Q_ASSERT(PyUnicode_Check(s));
25102510
funcName = PyUnicode_AsUTF8(s);
25112511
Py_DECREF(s);
25122512
}
@@ -2525,18 +2525,18 @@ QString PythonQtPrivate::getSignature(PyObject* object)
25252525
Q_ASSERT(PyTuple_Check(co_varnames));
25262526
for (int i=0; i<nargs; i++) {
25272527
PyObject* name = PyTuple_GetItem(co_varnames, i);
2528-
Q_ASSERT(PyString_Check(name));
2528+
Q_ASSERT(PyUnicode_Check(name));
25292529
arguments << PyUnicode_AsUTF8(name);
25302530
}
25312531
if (code->co_flags & CO_VARARGS) {
25322532
PyObject* s = PyTuple_GetItem(co_varnames, nargs);
2533-
Q_ASSERT(PyString_Check(s));
2533+
Q_ASSERT(PyUnicode_Check(s));
25342534
varargs = PyUnicode_AsUTF8(s);
25352535
nargs += 1;
25362536
}
25372537
if (code->co_flags & CO_VARKEYWORDS) {
25382538
PyObject* s = PyTuple_GetItem(co_varnames, nargs);
2539-
Q_ASSERT(PyString_Check(s));
2539+
Q_ASSERT(PyUnicode_Check(s));
25402540
varkeywords = PyUnicode_AsUTF8(s);
25412541
}
25422542
Py_DECREF(co_varnames);
@@ -2548,7 +2548,7 @@ QString PythonQtPrivate::getSignature(PyObject* object)
25482548
for (Py_ssize_t i=0; i<PyTuple_Size(defaultsTuple); i++) {
25492549
PyObject* d = PyTuple_GetItem(defaultsTuple, i);
25502550
PyObject* s = PyObject_Repr(d);
2551-
Q_ASSERT(PyString_Check(s));
2551+
Q_ASSERT(PyUnicode_Check(s));
25522552
defaults << PyUnicode_AsUTF8(s);
25532553
Py_DECREF(s);
25542554
}

src/PythonQtPythonInclude.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,10 @@
121121
#define PY3K
122122
// Helper defines to facilitate porting
123123
#define PyString_FromString PyUnicode_FromString
124-
#define PyString_Check PyUnicode_Check
125124

126125
#else
127126
// Defines to use Python 3 names in Python 2 code
128127
#define PyBytes_Type PyString_Type
129-
#define PyBytes_Check PyString_Check
130128
#define PyBytes_GET_SIZE PyString_GET_SIZE
131129
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
132130
#endif

0 commit comments

Comments
 (0)