Closed rgaudin closed 1 year ago
I confirm that https://github.com/openzim/libzim/pull/496 fixes the issue and works as expected.
Test needs to be written as
def test_exc_in_indexdata(fpath, lipsum):
item = StaticItem(path=HOME_PATH + "custom", content=lipsum, mimetype="text/html")
class CustomIndexData(IndexData):
def has_indexdata(self):
raise IndexError
item.get_indexdata = CustomIndexData
with pytest.raises(RuntimeError, match="IndexError"):
with Creator(fpath).config_indexing(True, "eng") as c:
c.add_item(item)
because indexing is done in a separate thread and thus raises on the Creator and not on the add_item()
call.
> self.c_creator.finishZimCreation()
E RuntimeError: Asynchronous error: St13runtime_error
E Traceback (most recent call last):
E File "libzim/libzim.pyx", line 145, in libzim.bool_cy_call_fct
E return call_method(obj, method)
E File "libzim/libzim.pyx", line 84, in libzim.call_method
E return func()
E File "/Users/reg/src/pylibzim/tests/test_libzim_creator.py", line 705, in has_indexdata
E raise IndexError
E IndexError
libzim/libzim.pyx:407: RuntimeError
Raising within finishZimCreation
here as we have a single entry
This can't be closed until we compile against that libzim version and add aforementioned test
@rgaudin libzim 8.1.0 has been published
Exceptions raised in
IndexData
's implementation methods (#149) crashes Python.