@@ -216,9 +216,9 @@ int ctkPythonConsoleCompleterPrivate::parameterCountBuiltInFunction(const QStrin
216216 if (PyObject_HasAttrString (pFunction, " __doc__" ))
217217 {
218218 PyObject* pDoc = PyObject_GetAttrString (pFunction, " __doc__" );
219- if (PyString_Check (pDoc))
219+ if (PyUnicode_Check (pDoc))
220220 {
221- QString docString = PyString_AsString (pDoc);
221+ QString docString = PyUnicode_AsUTF8 (pDoc);
222222 QString argumentExtract = docString.mid (docString.indexOf (" (" )+1 , docString.indexOf (" )" ) - docString.indexOf (" (" )-1 );
223223 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
224224 QStringList arguments = argumentExtract.split (" ," , Qt::SkipEmptyParts);
@@ -247,7 +247,7 @@ int ctkPythonConsoleCompleterPrivate::parameterCountUserDefinedFunction(const QS
247247 PyObject* ac = PyObject_GetAttrString (fc, " co_argcount" );
248248 if (ac)
249249 {
250- parameterCount = PyInt_AsLong (ac);
250+ parameterCount = PyLong_AsLong (ac);
251251 Py_DECREF (ac);
252252 }
253253 Py_DECREF (fc);
@@ -269,7 +269,7 @@ int ctkPythonConsoleCompleterPrivate::parameterCountUserDefinedClassFunction(con
269269 PyObject* ac = PyObject_GetAttrString (fc, " co_argcount" );
270270 if (ac)
271271 {
272- parameterCount = PyInt_AsLong (ac);
272+ parameterCount = PyLong_AsLong (ac);
273273 Py_DECREF (ac);
274274 }
275275 Py_DECREF (fc);
@@ -288,9 +288,9 @@ int ctkPythonConsoleCompleterPrivate::parameterCountFromDocumentation(const QStr
288288 if (PyObject_HasAttrString (pFunction, " __call__" ))
289289 {
290290 PyObject* pDoc = PyObject_GetAttrString (pFunction, " __doc__" );
291- if (PyString_Check (pDoc))
291+ if (PyUnicode_Check (pDoc))
292292 {
293- QString docString = PyString_AsString (pDoc);
293+ QString docString = PyUnicode_AsUTF8 (pDoc);
294294 QString argumentExtract = docString.mid (docString.indexOf (" (" )+1 , docString.indexOf (" )" ) - docString.indexOf (" (" )-1 );
295295 #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
296296 QStringList arguments = argumentExtract.split (" ," , Qt::SkipEmptyParts);
@@ -677,28 +677,28 @@ void ctkPythonConsole::initialize(ctkAbstractPythonManager* newPythonManager)
677677QString ctkPythonConsole::ps1 () const
678678{
679679 PyObject * ps1 = PySys_GetObject (const_cast <char *>(" ps1" ));
680- const char * ps1_str = PyString_AsString (ps1);
680+ const char * ps1_str = PyUnicode_AsUTF8 (ps1);
681681 return QLatin1String (ps1_str);
682682}
683683
684684// ----------------------------------------------------------------------------
685685void ctkPythonConsole::setPs1 (const QString& newPs1)
686686{
687- PySys_SetObject (const_cast <char *>(" ps1" ), PyString_FromString (newPs1.toLatin1 ().data ()));
687+ PySys_SetObject (const_cast <char *>(" ps1" ), PyUnicode_FromString (newPs1.toLatin1 ().data ()));
688688}
689689
690690// ----------------------------------------------------------------------------
691691QString ctkPythonConsole::ps2 () const
692692{
693693 PyObject * ps2 = PySys_GetObject (const_cast <char *>(" ps2" ));
694- const char * ps2_str = PyString_AsString (ps2);
694+ const char * ps2_str = PyUnicode_AsUTF8 (ps2);
695695 return QLatin1String (ps2_str);
696696}
697697
698698// ----------------------------------------------------------------------------
699699void ctkPythonConsole::setPs2 (const QString& newPs2)
700700{
701- PySys_SetObject (const_cast <char *>(" ps2" ), PyString_FromString (newPs2.toLatin1 ().data ()));
701+ PySys_SetObject (const_cast <char *>(" ps2" ), PyUnicode_FromString (newPs2.toLatin1 ().data ()));
702702}
703703
704704// ----------------------------------------------------------------------------
0 commit comments