Skip to content

Commit 5125de8

Browse files
committed
Fixed #141: forwarding libzim exception in addIllustration()
1 parent 79b8ef1 commit 5125de8

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

libzim/libzim.pyx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,12 @@ cdef class _Creator:
287287
def add_illustration(self, int size: pyint, content: bytes):
288288
"""Add a PNG illustration to Archive
289289
290-
https://wiki.openzim.org/wiki/Metadata"""
290+
https://wiki.openzim.org/wiki/Metadata
291+
292+
Raises
293+
------
294+
RuntimeError
295+
If an Illustration exists with the same size"""
291296
cdef string _content = content
292297
self.c_creator.addIllustration(size, _content)
293298

libzim/zim.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ cdef extern from "zim/writer/creator.h" namespace "zim::writer":
6464
void addRedirection(string path, string title, string targetpath, map[HintKeys, uint64_t] hints) nogil except +
6565
void finishZimCreation() nogil except +
6666
void setMainPath(string mainPath)
67-
void addIllustration(unsigned int size, string content)
67+
void addIllustration(unsigned int size, string content) nogil except +
6868

6969
cdef extern from "zim/search.h" namespace "zim":
7070
cdef cppclass Query:

tests/test_libzim_creator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ def test_creator_metadata_overwrite(fpath, lipsum_item, favicon_data):
433433

434434
c.add_illustration(48, favicon_data)
435435
# this currently segfaults but it should not
436-
# with pytest.raises(RuntimeError, match="Impossible to add"):
437-
# c.add_illustration(48, favicon_data)
436+
with pytest.raises(RuntimeError, match="Impossible to add"):
437+
c.add_illustration(48, favicon_data)
438438
zim = Archive(fpath)
439439
assert zim.get_metadata("Key").decode("UTF-8") == "first"
440440

0 commit comments

Comments
 (0)