From 38d11bbe147fc0f1b3d8d0df0eb8558f189f2029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Neuh=C3=A4user?= Date: Thu, 17 Jun 2010 05:56:06 +0200 Subject: [PATCH] the sphinx.search.js_index is now able to load and dump data from binary streams --- sphinx/search.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sphinx/search.py b/sphinx/search.py index 729b63b2a..6d5a0614d 100644 --- a/sphinx/search.py +++ b/sphinx/search.py @@ -58,10 +58,13 @@ class _JavaScriptIndex(object): return jsdump.loads(data) def dump(self, data, f): - f.write(self.dumps(data)) + f.write(self.dumps(data).encode('utf-8')) def load(self, f): - return self.loads(f.read()) + data = f.read() + if isinstance(data, unicode): + return self.loads(data) + return self.loads(data.decode('utf-8')) js_index = _JavaScriptIndex()