From 4b60a6a4621f4fd33593f530e3b39152dcba0ba7 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Fri, 7 Dec 2018 19:00:45 +0100 Subject: [PATCH] Python: highlight method: no need to copy the output unicode object --- src/python/recoll/pyrecoll.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/python/recoll/pyrecoll.cpp b/src/python/recoll/pyrecoll.cpp index 78950809..a47bbfab 100644 --- a/src/python/recoll/pyrecoll.cpp +++ b/src/python/recoll/pyrecoll.cpp @@ -1293,10 +1293,11 @@ Query_highlight(recoll_QueryObject* self, PyObject *args, PyObject *kwargs) PyErr_SetString(PyExc_ValueError, "Plaintorich failed"); return 0; } + // cf python manual:The bytes will be interpreted as being UTF-8 encoded. PyObject* unicode = PyUnicode_FromStringAndSize(out.begin()->c_str(), out.begin()->size()); - return Py_BuildValue("u#", PyUnicode_AsUnicode(unicode), - PyUnicode_GetSize(unicode)); + // We used to return a copy of the unicode object. Can't see why any more + return unicode; } PyDoc_STRVAR(doc_Query_makedocabstract,