mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 18:56:17 +03:00
Merge pull request #3341 from radarhere/webp_fp
Close existing WebP fp before setting new fp
This commit is contained in:
commit
9a420fc6ca
|
@ -135,6 +135,13 @@ class TestFileWebp(PillowTestCase):
|
|||
self.assertRaises(TypeError, _webp.WebPAnimDecoder)
|
||||
self.assertRaises(TypeError, _webp.WebPDecode)
|
||||
|
||||
def test_no_resource_warning(self):
|
||||
file_path = "Tests/images/hopper.webp"
|
||||
image = Image.open(file_path)
|
||||
|
||||
temp_file = self.tempfile("temp.webp")
|
||||
self.assert_warning(None, image.save, temp_file)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -153,6 +153,8 @@ class WebPImageFile(ImageFile.ImageFile):
|
|||
self.__loaded = self.__logical_frame
|
||||
|
||||
# Set tile
|
||||
if self.fp:
|
||||
self.fp.close()
|
||||
self.fp = BytesIO(data)
|
||||
self.tile = [("raw", (0, 0) + self.size, 0, self.mode)]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user