diff options
author | Dimitri John Ledkov <xnox@ubuntu.com> | 2019-12-03 22:59:35 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2019-12-05 15:06:44 +0100 |
commit | 12a74c66c6656bbf6a89bfae83b76e3df37d9199 (patch) | |
tree | 189bc4543ff839662d4032dbf66cd2e283f17829 /src/pyutils.h | |
parent | 23d818175a81e46a899c5e8b00be54cfa0881a4e (diff) | |
download | fork-ledger-12a74c66c6656bbf6a89bfae83b76e3df37d9199.tar.gz fork-ledger-12a74c66c6656bbf6a89bfae83b76e3df37d9199.tar.bz2 fork-ledger-12a74c66c6656bbf6a89bfae83b76e3df37d9199.zip |
Port to python3
Diffstat (limited to 'src/pyutils.h')
-rw-r--r-- | src/pyutils.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/pyutils.h b/src/pyutils.h index 641dbd3b..323ffe02 100644 --- a/src/pyutils.h +++ b/src/pyutils.h @@ -130,8 +130,12 @@ template <typename T> PyObject * str_to_py_unicode(const T& str) { using namespace boost::python; +#if PY_MAJOR_VERSION >= 3 + PyObject * uni = PyUnicode_FromString(str.c_str()); +#else PyObject * pstr = PyString_FromString(str.c_str()); PyObject * uni = PyUnicode_FromEncodedObject(pstr, "UTF-8", NULL); +#endif return object(handle<>(borrowed(uni))).ptr(); } |