There is one suspicious thing in
mergeProject() in
DocumentPyImp.cpp, namely Python argument parsing in the first if-clause.
Code: Select all
PyObject* DocumentPy::mergeProject(PyObject * args)
{
char* filename;
if (!PyArg_ParseTuple(args, "s", &filename)) // convert args: Python->C
return NULL; // NULL triggers exception
PY_TRY {
Base::FileInfo fi(filename);
Base::ifstream str(fi, std::ios::in | std::ios::binary);
App::Document* doc = getDocumentPtr();
MergeDocuments md(doc);
md.importObjects(str);
Py_Return;
} PY_CATCH;
}
The Python documentation in
https://docs.python.org/3/c-api/arg.html says about the 's' conversion that
Note
This format does not accept bytes-like objects. If you want to accept filesystem paths and convert them to C character strings, it is preferable to use the O& format with PyUnicode_FSConverter() as converter.
This implies that filesystem paths should be converted with 'O&' style, and I modified and compiled the source with this change. Unfortunately, on Linux, it seems both ways work ok, so I'm not able to debug the problem as I can't make it fail. But if anyone being able to compile with windows could try to replace
Code: Select all
if (!PyArg_ParseTuple(args, "s", &filename)) // convert args: Python->C
on line 178 of
DocumentPyImp.cpp with
Code: Select all
if (!PyArg_ParseTuple(args, "O&", &PyUnicode_FSConverter, (void *)&filename))
and recompile, and see if it fixes the problem. The 'O&' version should be the correct one according to the documentation, and there are other places in the same class that should be fixed, too. But let's first see if this is the problem, or if it's still something else.