Skip to content
Permalink
Browse files

fix python error on startup on windows

  • Loading branch information
jef-n committed Nov 16, 2015
1 parent 5129527 commit b7fea5726ae2175e865437fc3a1a336cff3e89a1
Showing with 16 additions and 1 deletion.
  1. +16 −1 src/python/qgspythonutilsimpl.cpp
@@ -399,7 +399,13 @@ QString QgsPythonUtilsImpl::getTraceback()
TRACEBACK_FETCH_ERROR( "getvalue() failed." );

/* And it should be a string all ready to go - duplicate it. */
if ( !PyUnicode_Check( obResult ) )
if ( !
#ifdef PYTHON2
PyString_Check( obResult )
#else
PyUnicode_Check( obResult )
#endif
)
TRACEBACK_FETCH_ERROR( "getvalue() did not return a string" );

result = PYOBJ2QSTRING( obResult );
@@ -506,7 +512,16 @@ QString QgsPythonUtilsImpl::PyObjectToQString( PyObject* obj )
// check whether the object is already a unicode string
if ( PyUnicode_Check( obj ) )
{
#ifdef PYTHON2
PyObject* utf8 = PyUnicode_AsUTF8String( obj );
if ( utf8 )
result = QString::fromUtf8( PyString_AS_STRING( utf8 ) );
else
result = "(qgis error)";
Py_XDECREF( utf8 );
#else
result = PYOBJ2QSTRING( obj );
#endif
return result;
}

0 comments on commit b7fea57

Please sign in to comment.
You can’t perform that action at this time.