Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in getIndexData crashes interpretor #153

Closed
rgaudin opened this issue Sep 26, 2022 · 3 comments · Fixed by openzim/libzim#496
Closed

Exception in getIndexData crashes interpretor #153

rgaudin opened this issue Sep 26, 2022 · 3 comments · Fixed by openzim/libzim#496
Assignees
Labels
bug Something isn't working upstream
Milestone

Comments

@rgaudin
Copy link
Member

rgaudin commented Sep 26, 2022

Exceptions raised in IndexData's implementation methods (#149) crashes Python.

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 Creator(fpath).config_indexing(True, "eng") as c:
        c.add_item(item)
@rgaudin rgaudin added the bug Something isn't working label Sep 26, 2022
@rgaudin rgaudin added this to the 2.1.0 milestone Sep 26, 2022
@rgaudin
Copy link
Member Author

rgaudin commented Oct 3, 2022

I confirm that openzim/libzim#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

@rgaudin
Copy link
Member Author

rgaudin commented Oct 4, 2022

This can't be closed until we compile against that libzim version and add aforementioned test

@kelson42
Copy link
Contributor

@rgaudin libzim 8.1.0 has been published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants