File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -399,7 +399,13 @@ QString QgsPythonUtilsImpl::getTraceback()
399
399
TRACEBACK_FETCH_ERROR ( " getvalue() failed." );
400
400
401
401
/* And it should be a string all ready to go - duplicate it. */
402
- if ( !PyUnicode_Check ( obResult ) )
402
+ if ( !
403
+ #ifdef PYTHON2
404
+ PyString_Check ( obResult )
405
+ #else
406
+ PyUnicode_Check ( obResult )
407
+ #endif
408
+ )
403
409
TRACEBACK_FETCH_ERROR ( " getvalue() did not return a string" );
404
410
405
411
result = PYOBJ2QSTRING ( obResult );
@@ -506,7 +512,16 @@ QString QgsPythonUtilsImpl::PyObjectToQString( PyObject* obj )
506
512
// check whether the object is already a unicode string
507
513
if ( PyUnicode_Check ( obj ) )
508
514
{
515
+ #ifdef PYTHON2
516
+ PyObject* utf8 = PyUnicode_AsUTF8String ( obj );
517
+ if ( utf8 )
518
+ result = QString::fromUtf8 ( PyString_AS_STRING ( utf8 ) );
519
+ else
520
+ result = " (qgis error)" ;
521
+ Py_XDECREF ( utf8 );
522
+ #else
509
523
result = PYOBJ2QSTRING ( obj );
524
+ #endif
510
525
return result;
511
526
}
512
527
You can’t perform that action at this time.
0 commit comments