add encoding parameter to .as_std_string()

to handle PyUnicode Objects. Usually ASCII for object names and Utf-8
for file names and console output.
issue #995
This commit is contained in:
Sebastian Hoogen
2015-01-31 22:36:39 +01:00
committed by wmayer
parent 8ee81e0516
commit faac8c36ba
8 changed files with 31 additions and 31 deletions

View File

@@ -97,7 +97,7 @@ void CompleteGuiExport initCompleteGui()
Py::Callable method(handler.getAttr(std::string("GetClassName")));
Py::Tuple args;
Py::String result(method.apply(args));
type = result.as_std_string();
type = result.as_std_string("ascii");
if (type == "Gui::PythonWorkbench") {
Gui::Workbench* wb = Gui::WorkbenchManager::instance()->createWorkbench("DraftWorkbench", type);
handler.setAttr(std::string("__Workbench__"), Py::Object(wb->getPyObject(), true));
@@ -120,11 +120,11 @@ void CompleteGuiExport initCompleteGui()
Py::Object o = Py::type(e);
if (o.isString()) {
Py::String s(o);
Base::Console().Error("%s\n", s.as_std_string().c_str());
Base::Console().Error("%s\n", s.as_std_string("utf-8").c_str());
}
else {
Py::String s(o.repr());
Base::Console().Error("%s\n", s.as_std_string().c_str());
Base::Console().Error("%s\n", s.as_std_string("utf-8").c_str());
}
// Prints message to console window if we are in interactive mode
PyErr_Print();