diff --git a/CHANGES b/CHANGES index a5d6dc2e5..70c1e9fa8 100644 --- a/CHANGES +++ b/CHANGES @@ -39,6 +39,7 @@ Bugs fixed * #1580: Fix paragraphs in longtable don't work in Latex output * #1366: Fix centered image not centered in latex * #1860: Fix man page using ``:samp:`` with braces - font doesn't reset +* #1610 Sphinx crashes in japanese indexing in some systems. Release 1.3.3 (released Dec 2, 2015) ==================================== diff --git a/sphinx/search/ja.py b/sphinx/search/ja.py index 23de74d37..8536173ff 100644 --- a/sphinx/search/ja.py +++ b/sphinx/search/ja.py @@ -85,10 +85,15 @@ class MecabBinder(object): dict = options.get('dict') if dict: param += ' -d %s' % dict + + fs_enc = sys.getfilesystemencoding() or sys.getdefaultencoding() self.ctypes_libmecab = ctypes.CDLL(libpath) + self.ctypes_libmecab.mecab_new2.argtypes = (ctypes.c_char_p,) + self.ctypes_libmecab.mecab_new2.restype = ctypes.c_void_p + self.ctypes_libmecab.mecab_sparse_tostr.argtypes = (ctypes.c_void_p, ctypes.c_char_p) self.ctypes_libmecab.mecab_sparse_tostr.restype = ctypes.c_char_p - self.ctypes_mecab = self.ctypes_libmecab.mecab_new2(param) + self.ctypes_mecab = ctypes.c_void_p(self.ctypes_libmecab.mecab_new2(param.encode(fs_enc))) def __del__(self): if self.ctypes_libmecab: