what is causing this exception? Everytime this object (https://github.com/hiaselhans/OpenGlide ... _glider.py) is recalculated it throw the exception:
<unknown exception traceback><type 'exceptions.TypeError'>: cannot return std::string from Unicode object
any ideas?
Exception: cannot return std::string from Unicode object
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Exception: cannot return std::string from Unicode object
My first educated guess would be that .getIcon in the view provider proxy returns a unicode object (for the path). If this i the case, you can try to remove the whole function, as a workaround.
(In my version FreeCAD.getHomePath() returns a unicode object. )
(In my version FreeCAD.getHomePath() returns a unicode object. )
Re: Exception: cannot return std::string from Unicode object
perfect, thanks. With str(...) it works.
OS: Ubuntu 14.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.4531 (Git)
Branch: master
Hash: 8628a6e0e0ef9223bff722b1278e5211039ae1b7
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OS: Ubuntu 14.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.4531 (Git)
Branch: master
Hash: 8628a6e0e0ef9223bff722b1278e5211039ae1b7
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
Re: Exception: cannot return std::string from Unicode object
Code: Select all
diff --git a/src/Gui/ViewProviderPythonFeature.cpp b/src/Gui/ViewProviderPythonF
index f5f869e..3632b37 100644
--- a/src/Gui/ViewProviderPythonFeature.cpp
+++ b/src/Gui/ViewProviderPythonFeature.cpp
@@ -247,10 +247,10 @@ QIcon ViewProviderPythonFeatureImp::getIcon() const
Py::Callable method(vp.getAttr(std::string("getIcon")));
Py::Tuple args;
Py::String str(method.apply(args));
- std::string content = str.as_std_string();
+ std::string content = str.as_std_string("utf-8");
QPixmap icon;
// Check if the passed string is a filename, otherwise treat as
- QFileInfo fi(QString::fromAscii(content.c_str()));
+ QFileInfo fi(QString::fromUtf8(content.c_str()));
if (fi.isFile() && fi.exists()) {
icon.load(fi.absoluteFilePath());
} else {