Skip to content

Commit

Permalink
fix python error on startup on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Nov 16, 2015
1 parent 5129527 commit b7fea57
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/python/qgspythonutilsimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit b7fea57

Please sign in to comment.