Skip to content

Commit 2cf3dc9

Browse files
committed
COMP: Fix warnings: deprecated conversion from string constant to ‘char*
Ideally, would be great if the python maintainer could update the signature of the function to accept 'const char*' instead of 'char*'.
1 parent c5b73cc commit 2cf3dc9

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

src/PythonQt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ PythonQt::PythonQt(int flags, const QByteArray& pythonQtModuleName)
150150
_p->_PythonQtObjectPtr_metaId = qRegisterMetaType<PythonQtObjectPtr>("PythonQtObjectPtr");
151151

152152
if ((flags & PythonAlreadyInitialized) == 0) {
153-
Py_SetProgramName("PythonQt");
153+
Py_SetProgramName(const_cast<char*>("PythonQt"));
154154
if (flags & IgnoreSiteModule) {
155155
// this prevents the automatic importing of Python site files
156156
Py_NoSiteFlag = 1;

src/PythonQtConversion.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,8 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type)
977977
{
978978
if (PyMapping_Check(val)) {
979979
QMap<QString,QVariant> map;
980-
PyObject* items = PyMapping_Items(val);
980+
// PyObject* items = PyMapping_Items(val);
981+
PyObject* items = PyObject_CallMethod(val, const_cast<char*>("items"), NULL);
981982
if (items) {
982983
int count = PyList_Size(items);
983984
PyObject* value;

src/PythonQtSlot.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ PythonQtSlotInfo*
317317
PythonQtSlotFunction_GetSlotInfo(PyObject *op)
318318
{
319319
if (!PythonQtSlotFunction_Check(op)) {
320-
PyErr_BadInternalCall();
320+
PyErr_Format(PyExc_SystemError, "%s:%d: bad argument to internal function", __FILE__, __LINE__);
321321
return NULL;
322322
}
323323
return ((PythonQtSlotFunctionObject *)op) -> m_ml;
@@ -327,7 +327,7 @@ PyObject *
327327
PythonQtSlotFunction_GetSelf(PyObject *op)
328328
{
329329
if (!PythonQtSlotFunction_Check(op)) {
330-
PyErr_BadInternalCall();
330+
PyErr_Format(PyExc_SystemError, "%s:%d: bad argument to internal function", __FILE__, __LINE__);
331331
return NULL;
332332
}
333333
return ((PythonQtSlotFunctionObject *)op) -> m_self;
@@ -392,9 +392,9 @@ meth_get__self__(PythonQtSlotFunctionObject *m, void * /*closure*/)
392392
}
393393

394394
static PyGetSetDef meth_getsets [] = {
395-
{"__doc__", (getter)meth_get__doc__, NULL, NULL},
396-
{"__name__", (getter)meth_get__name__, NULL, NULL},
397-
{"__self__", (getter)meth_get__self__, NULL, NULL},
395+
{const_cast<char*>("__doc__"), (getter)meth_get__doc__, NULL, NULL},
396+
{const_cast<char*>("__name__"), (getter)meth_get__name__, NULL, NULL},
397+
{const_cast<char*>("__self__"), (getter)meth_get__self__, NULL, NULL},
398398
{NULL, NULL, NULL,NULL},
399399
};
400400

@@ -405,7 +405,7 @@ static PyGetSetDef meth_getsets [] = {
405405
#define OFF(x) offsetof(PythonQtSlotFunctionObject, x)
406406

407407
static PyMemberDef meth_members[] = {
408-
{"__module__", T_OBJECT, OFF(m_module), PY_WRITE_RESTRICTED},
408+
{const_cast<char*>("__module__"), T_OBJECT, OFF(m_module), PY_WRITE_RESTRICTED},
409409
{NULL}
410410
};
411411

src/PythonQtStdDecorators.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ public slots:
8080

8181
double static_Qt_qAbs(double a) { return qAbs(a); }
8282
double static_Qt_qBound(double a,double b,double c) { return qBound(a,b,c); }
83-
void static_Qt_qDebug(const QByteArray& msg) { qDebug(msg.constData()); }
83+
void static_Qt_qDebug(const QByteArray& msg) { qDebug("%s", msg.constData()); }
8484
// TODO: multi arg qDebug...
85-
void static_Qt_qWarning(const QByteArray& msg) { qWarning(msg.constData()); }
85+
void static_Qt_qWarning(const QByteArray& msg) { qWarning("%s", msg.constData()); }
8686
// TODO: multi arg qWarning...
87-
void static_Qt_qCritical(const QByteArray& msg) { qCritical(msg.constData()); }
87+
void static_Qt_qCritical(const QByteArray& msg) { qCritical("%s", msg.constData()); }
8888
// TODO: multi arg qCritical...
89-
void static_Qt_qFatal(const QByteArray& msg) { qFatal(msg.constData()); }
89+
void static_Qt_qFatal(const QByteArray& msg) { qFatal("%s", msg.constData()); }
9090
// TODO: multi arg qFatal...
9191
bool static_Qt_qFuzzyCompare(double a, double b) { return qFuzzyCompare(a, b); }
9292
double static_Qt_qMax(double a, double b) { return qMax(a, b); }

src/PythonQtStdOut.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ static PyMethodDef PythonQtStdOutRedirect_methods[] = {
8787
};
8888

8989
static PyMemberDef PythonQtStdOutRedirect_members[] = {
90-
{"softspace", T_INT, offsetof(PythonQtStdOutRedirect, softspace), 0,
91-
"soft space flag"
90+
{const_cast<char*>("softspace"), T_INT, offsetof(PythonQtStdOutRedirect, softspace), 0,
91+
const_cast<char*>("soft space flag")
9292
},
9393
{NULL} /* Sentinel */
9494
};

0 commit comments

Comments
 (0)