Skip to content

Commit

Permalink
Merge pull request #5404 from radarhere/feed
Browse files Browse the repository at this point in the history
Changed error type to allow for incremental WebP parsing
  • Loading branch information
radarhere committed Dec 28, 2021
2 parents e613366 + 35107e9 commit d8f2fb5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Tests/test_imagefile.py
Expand Up @@ -82,6 +82,19 @@ def test_ico(self):
p.feed(data)
assert (48, 48) == p.image.size

@skip_unless_feature("webp")
@skip_unless_feature("webp_anim")
def test_incremental_webp(self):
with ImageFile.Parser() as p:
with open("Tests/images/hopper.webp", "rb") as f:
p.feed(f.read(1024))

# Check that insufficient data was given in the first feed
assert not p.image

p.feed(f.read())
assert (128, 128) == p.image.size

@skip_unless_feature("zlib")
def test_safeblock(self):
im1 = hopper()
Expand Down
2 changes: 1 addition & 1 deletion src/_webp.c
Expand Up @@ -396,7 +396,7 @@ _anim_decoder_new(PyObject *self, PyObject *args) {
}
PyObject_Del(decp);
}
PyErr_SetString(PyExc_RuntimeError, "could not create decoder object");
PyErr_SetString(PyExc_OSError, "could not create decoder object");
return NULL;
}

Expand Down

0 comments on commit d8f2fb5

Please sign in to comment.