From e84a78d828845d7a87da8139d0f8ceeb0c40926e Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 19 Oct 2018 20:12:08 +1100 Subject: [PATCH] Only close existing fp if fp is exclusive --- Tests/test_file_webp.py | 1 - src/PIL/WebPImagePlugin.py | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/test_file_webp.py b/Tests/test_file_webp.py index 956a26996..399b585e8 100644 --- a/Tests/test_file_webp.py +++ b/Tests/test_file_webp.py @@ -139,7 +139,6 @@ class TestFileWebp(PillowTestCase): self.assertRaises(TypeError, _webp.WebPAnimDecoder) self.assertRaises(TypeError, _webp.WebPDecode) - @unittest.skip("Currently is not working") def test_no_resource_warning(self): file_path = "Tests/images/hopper.webp" image = Image.open(file_path) diff --git a/src/PIL/WebPImagePlugin.py b/src/PIL/WebPImagePlugin.py index 1e9a028a7..eb4618a16 100644 --- a/src/PIL/WebPImagePlugin.py +++ b/src/PIL/WebPImagePlugin.py @@ -163,6 +163,8 @@ class WebPImageFile(ImageFile.ImageFile): self.__loaded = self.__logical_frame # Set tile + if self.fp and self._exclusive_fp: + self.fp.close() self.fp = BytesIO(data) self.tile = [("raw", (0, 0) + self.size, 0, self.rawmode)]