Fix #1610: Sphinx cause AttributeError when MeCab search option is enabled and python-mecab is not installed.

This commit is contained in:
Takayuki Shimizukawa 2014-10-29 01:08:47 +09:00
parent 6227082061
commit 4dd1c538d5
2 changed files with 4 additions and 3 deletions

View File

@ -22,6 +22,8 @@ Bugs fixed
a toctree was replaced with wrong title and link.
* #1584: Point to master doc in HTML "top" link.
* #1585: Autosummary of modules broken in Sphinx-1.2.3.
* #1610: Sphinx cause AttributeError when MeCab search option is enabled and
python-mecab is not installed.
Release 1.2.3 (released Sep 1, 2014)

View File

@ -46,7 +46,7 @@ class MecabBinder(object):
result = self.native.parse(input2)
else:
result = self.ctypes_libmecab.mecab_sparse_tostr(
self.ctypes_mecab, input)
self.ctypes_mecab, input.encode(self.dict_encode))
return result.decode(self.dict_encode).split(' ')
def init_native(self, options):
@ -83,7 +83,7 @@ class MecabBinder(object):
self.ctypes_libmecab = ctypes.CDLL(libpath)
self.ctypes_libmecab.mecab_sparse_tostr.restype = ctypes.c_char_p
self.ctypes_mecab = self.libmecab.mecab_new2(param)
self.ctypes_mecab = self.ctypes_libmecab.mecab_new2(param)
def __del__(self):
if self.ctypes_libmecab:
@ -260,7 +260,6 @@ class SearchJapanese(SearchLanguage):
if type not in ('mecab', 'default'):
raise ValueError(("Japanese tokenizer's type should be 'mecab'"
" or 'default'"))
self.libmecab = None
if type == 'mecab':
self.splitter = MecabBinder(options)
else: