From 94f2dc2843db9efbdbcfcef44f49cbd1bd7098cd Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Wed, 18 May 2016 11:48:36 +0300 Subject: [PATCH] Make Xapian search work with Python 3 --- sphinx/websupport/search/xapiansearch.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sphinx/websupport/search/xapiansearch.py b/sphinx/websupport/search/xapiansearch.py index ee9b33da7..1e43dcbe9 100644 --- a/sphinx/websupport/search/xapiansearch.py +++ b/sphinx/websupport/search/xapiansearch.py @@ -11,6 +11,8 @@ import xapian +from six import string_types + from sphinx.util.osutil import ensuredir from sphinx.websupport.search import BaseSearch @@ -73,7 +75,10 @@ class XapianSearch(BaseSearch): results = [] for m in matches: - context = self.extract_context(m.document.get_data()) + data = m.document.get_data() + if not isinstance(data, string_types): + data = data.decode("utf-8") + context = self.extract_context(data) results.append((m.document.get_value(self.DOC_PATH), m.document.get_value(self.DOC_TITLE), ''.join(context)))