@@ -127,7 +127,7 @@ bool QgsPythonUtilsImpl::checkSystemImports()
127
127
return false ;
128
128
}
129
129
}
130
- #ifdef PYTHON2
130
+ #if (PY_VERSION_HEX < 0x03000000)
131
131
// import Qt bindings
132
132
if ( !runString ( " from PyQt4 import QtCore, QtGui" ,
133
133
QObject::tr ( " Couldn't load PyQt." ) + ' \n ' + QObject::tr ( " Python support will be disabled." ) ) )
@@ -365,7 +365,7 @@ QString QgsPythonUtilsImpl::getTraceback()
365
365
PyErr_Fetch ( &type, &value, &traceback );
366
366
PyErr_NormalizeException ( &type, &value, &traceback );
367
367
368
- #ifdef PYTHON2
368
+ #if (PY_VERSION_HEX < 0x03000000)
369
369
const char * iomod = " cStringIO" ;
370
370
#else
371
371
const char * iomod = " io" ;
@@ -403,7 +403,7 @@ QString QgsPythonUtilsImpl::getTraceback()
403
403
404
404
/* And it should be a string all ready to go - duplicate it. */
405
405
if ( !
406
- #ifdef PYTHON2
406
+ #if (PY_VERSION_HEX < 0x03000000)
407
407
PyString_Check ( obResult )
408
408
#else
409
409
PyUnicode_Check ( obResult )
@@ -440,7 +440,7 @@ QString QgsPythonUtilsImpl::getTypeAsString( PyObject* obj )
440
440
if ( !obj )
441
441
return nullptr ;
442
442
443
- #ifdef PYTHON2
443
+ #if (PY_VERSION_HEX < 0x03000000)
444
444
if ( PyClass_Check ( obj ) )
445
445
{
446
446
QgsDebugMsg ( " got class" );
@@ -515,20 +515,11 @@ QString QgsPythonUtilsImpl::PyObjectToQString( PyObject* obj )
515
515
// check whether the object is already a unicode string
516
516
if ( PyUnicode_Check ( obj ) )
517
517
{
518
- #ifdef PYTHON2
519
- PyObject* utf8 = PyUnicode_AsUTF8String ( obj );
520
- if ( utf8 )
521
- result = QString::fromUtf8 ( PyString_AS_STRING ( utf8 ) );
522
- else
523
- result = " (qgis error)" ;
524
- Py_XDECREF ( utf8 );
525
- #else
526
518
result = PYOBJ2QSTRING ( obj );
527
- #endif
528
519
return result;
529
520
}
530
521
531
- #if PYTHON2
522
+ #if (PY_VERSION_HEX < 0x03000000)
532
523
// check whether the object is a classical (8-bit) string
533
524
if ( PyString_Check ( obj ) )
534
525
{
0 commit comments