mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #1610: Sphinx cause AttributeError when MeCab search option is enabled and python-mecab is not installed.
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -22,6 +22,8 @@ Bugs fixed
|
|||||||
a toctree was replaced with wrong title and link.
|
a toctree was replaced with wrong title and link.
|
||||||
* #1584: Point to master doc in HTML "top" link.
|
* #1584: Point to master doc in HTML "top" link.
|
||||||
* #1585: Autosummary of modules broken in Sphinx-1.2.3.
|
* #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)
|
Release 1.2.3 (released Sep 1, 2014)
|
||||||
|
@@ -46,7 +46,7 @@ class MecabBinder(object):
|
|||||||
result = self.native.parse(input2)
|
result = self.native.parse(input2)
|
||||||
else:
|
else:
|
||||||
result = self.ctypes_libmecab.mecab_sparse_tostr(
|
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(' ')
|
return result.decode(self.dict_encode).split(' ')
|
||||||
|
|
||||||
def init_native(self, options):
|
def init_native(self, options):
|
||||||
@@ -83,7 +83,7 @@ class MecabBinder(object):
|
|||||||
|
|
||||||
self.ctypes_libmecab = ctypes.CDLL(libpath)
|
self.ctypes_libmecab = ctypes.CDLL(libpath)
|
||||||
self.ctypes_libmecab.mecab_sparse_tostr.restype = ctypes.c_char_p
|
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):
|
def __del__(self):
|
||||||
if self.ctypes_libmecab:
|
if self.ctypes_libmecab:
|
||||||
@@ -260,7 +260,6 @@ class SearchJapanese(SearchLanguage):
|
|||||||
if type not in ('mecab', 'default'):
|
if type not in ('mecab', 'default'):
|
||||||
raise ValueError(("Japanese tokenizer's type should be 'mecab'"
|
raise ValueError(("Japanese tokenizer's type should be 'mecab'"
|
||||||
" or 'default'"))
|
" or 'default'"))
|
||||||
self.libmecab = None
|
|
||||||
if type == 'mecab':
|
if type == 'mecab':
|
||||||
self.splitter = MecabBinder(options)
|
self.splitter = MecabBinder(options)
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user