issue #1027 use unicode filepaths

This commit is contained in:
Sebastian Hoogen
2014-09-21 23:45:32 +02:00
committed by wmayer
parent 7db2cdc008
commit 01cf0f5872
28 changed files with 396 additions and 243 deletions

View File

@@ -180,12 +180,14 @@ PyObject* Application::sLoadFile(PyObject * /*self*/, PyObject *args,PyObject *
PyObject* Application::sOpenDocument(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
char *pstr;
if (!PyArg_ParseTuple(args, "s", &pstr)) // convert args: Python->C
return NULL; // NULL triggers exception
char* Name;
if (!PyArg_ParseTuple(args, "et","utf-8",&Name))
return NULL;
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
try {
// return new document
return (GetApplication().openDocument(pstr)->getPyObject());
return (GetApplication().openDocument(EncodedName.c_str())->getPyObject());
}
catch (const Base::Exception& e) {
PyErr_SetString(PyExc_IOError, e.what());
@@ -193,7 +195,7 @@ PyObject* Application::sOpenDocument(PyObject * /*self*/, PyObject *args,PyObjec
}
catch (const std::exception& e) {
// might be subclass from zipios
PyErr_Format(PyExc_IOError, "Invalid project file %s: %s\n", pstr, e.what());
PyErr_Format(PyExc_IOError, "Invalid project file %s: %s\n", EncodedName.c_str(), e.what());
return 0L;
}
}