Skip to content

Commit 2e9030d

Browse files
committed
Initialise __frame = 0 in open, and test tell
1 parent 1c2b2b0 commit 2e9030d

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Tests/test_file_png.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,10 @@ def test_exif_argument(self, tmp_path):
629629
with Image.open(test_file) as reloaded:
630630
assert reloaded.info["exif"] == b"Exif\x00\x00exifstring"
631631

632+
def test_tell(self, tmp_path):
633+
with Image.open(TEST_PNG_FILE) as im:
634+
assert im.tell() == 0
635+
632636
def test_seek(self, tmp_path):
633637
with Image.open(TEST_PNG_FILE) as im:
634638
im.seek(0)

src/PIL/PngImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,13 +630,13 @@ class PngImageFile(ImageFile.ImageFile):
630630

631631
format = "PNG"
632632
format_description = "Portable network graphics"
633-
__frame = 0
634633

635634
def _open(self):
636635

637636
if self.fp.read(8) != _MAGIC:
638637
raise SyntaxError("not a PNG file")
639638
self.__fp = self.fp
639+
self.__frame = 0
640640

641641
#
642642
# Parse headers up to the first IDAT or fDAT chunk

0 commit comments

Comments
 (0)