From 35107e96375346e84c1f0d1e90ff6149fbe06a08 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 14 Apr 2021 20:01:56 +1000 Subject: [PATCH] Changed failure to create decoder to OSError for Parser --- Tests/test_imagefile.py | 13 +++++++++++++ src/_webp.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Tests/test_imagefile.py b/Tests/test_imagefile.py index b4107e8e3a6..862da5a1b92 100644 --- a/Tests/test_imagefile.py +++ b/Tests/test_imagefile.py @@ -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() diff --git a/src/_webp.c b/src/_webp.c index 4d51d99dfa6..0c2dacadcc5 100644 --- a/src/_webp.c +++ b/src/_webp.c @@ -395,7 +395,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; }