From f6d90cef122ba82e4924b42e95a87a67372fc267 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 2 Apr 2020 08:49:26 +0300 Subject: [PATCH] Initialise __frame = 0 in open, and test tell --- Tests/test_file_png.py | 4 ++++ src/PIL/PngImagePlugin.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index d095c26a1..f4b0de81b 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -629,6 +629,10 @@ class TestFilePng: with Image.open(test_file) as reloaded: assert reloaded.info["exif"] == b"Exif\x00\x00exifstring" + def test_tell(self, tmp_path): + with Image.open(TEST_PNG_FILE) as im: + assert im.tell() == 0 + def test_seek(self, tmp_path): with Image.open(TEST_PNG_FILE) as im: im.seek(0) diff --git a/src/PIL/PngImagePlugin.py b/src/PIL/PngImagePlugin.py index 2c51caf47..0291df4b0 100644 --- a/src/PIL/PngImagePlugin.py +++ b/src/PIL/PngImagePlugin.py @@ -630,13 +630,13 @@ class PngImageFile(ImageFile.ImageFile): format = "PNG" format_description = "Portable network graphics" - __frame = 0 def _open(self): if self.fp.read(8) != _MAGIC: raise SyntaxError("not a PNG file") self.__fp = self.fp + self.__frame = 0 # # Parse headers up to the first IDAT or fDAT chunk