Skip to content

Commit

Permalink
+ handle unicode strings in class PythonWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 19, 2014
1 parent 7a201f9 commit b11acfd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Gui/WidgetFactory.cpp
Expand Up @@ -134,6 +134,15 @@ PythonWrapper::PythonWrapper()

bool PythonWrapper::toCString(const Py::Object& pyobject, std::string& str)
{
if (PyUnicode_Check(pyobject.ptr())) {
PyObject* unicode = PyUnicode_AsUTF8String(pyobject.ptr());
str = PyString_AsString(unicode);
Py_DECREF(unicode);
return true;
}
else if (PyString_Check(pyobject.ptr())) {
str = PyString_AsString(pyobject.ptr());
}
#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE)
if (Shiboken::String::check(pyobject.ptr())) {
const char* s = Shiboken::String::toCString(pyobject.ptr());
Expand Down

0 comments on commit b11acfd

Please sign in to comment.