From 9e75213c928cbc6fa192b9877d3db47f05d854f1 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 22 Mar 2016 12:20:58 -0300 Subject: [PATCH] Document.openTransaction() now accepts unicode --- src/App/DocumentPyImp.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index 2f0d15cf0..ef72547df 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -319,10 +319,18 @@ PyObject* DocumentPy::moveObject(PyObject *args) PyObject* DocumentPy::openTransaction(PyObject *args) { + PyObject *value; + if (!PyArg_ParseTuple(args, "|O",&value)) + return NULL; // NULL triggers exception char *pstr=0; - if (!PyArg_ParseTuple(args, "|s", &pstr)) // convert args: Python->C - return NULL; // NULL triggers exception - + if (PyUnicode_Check(value)) { + PyObject* unicode = PyUnicode_AsLatin1String(value); + pstr = PyString_AsString(unicode); + Py_DECREF(unicode); + } + else if (PyString_Check(value)) { + pstr = PyString_AsString(value); + } getDocumentPtr()->openTransaction(pstr); Py_Return; }