Fix Sphinx crashes if mecab initialization failed

This commit is contained in:
Takeshi KOMIYA 2016-01-08 21:36:42 +09:00
parent fe101177c3
commit 85a9e820dc
2 changed files with 6 additions and 2 deletions

View File

@ -39,7 +39,8 @@ 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.
* #1610: Sphinx crashes in japanese indexing in some systems
* Fix Sphinx crashes if mecab initialization failed
Release 1.3.3 (released Dec 2, 2015)
====================================

View File

@ -29,6 +29,7 @@ try:
except ImportError:
native_module = False
from sphinx.errors import SphinxError
from sphinx.search import SearchLanguage
@ -93,7 +94,9 @@ class MecabBinder(object):
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 = ctypes.c_void_p(self.ctypes_libmecab.mecab_new2(param.encode(fs_enc)))
self.ctypes_mecab = self.ctypes_libmecab.mecab_new2(param.encode(fs_enc))
if self.ctypes_mecab is None:
raise SphinxError('mecab initialization failed')
def __del__(self):
if self.ctypes_libmecab: