Initialise __frame = 0 in open, and test tell

This commit is contained in:
Hugo 2020-04-02 08:49:26 +03:00
parent 1c2b2b085a
commit 2e9030ddca
2 changed files with 5 additions and 1 deletions

View File

@ -629,6 +629,10 @@ class TestFilePng:
with Image.open(test_file) as reloaded: with Image.open(test_file) as reloaded:
assert reloaded.info["exif"] == b"Exif\x00\x00exifstring" 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): def test_seek(self, tmp_path):
with Image.open(TEST_PNG_FILE) as im: with Image.open(TEST_PNG_FILE) as im:
im.seek(0) im.seek(0)

View File

@ -630,13 +630,13 @@ class PngImageFile(ImageFile.ImageFile):
format = "PNG" format = "PNG"
format_description = "Portable network graphics" format_description = "Portable network graphics"
__frame = 0
def _open(self): def _open(self):
if self.fp.read(8) != _MAGIC: if self.fp.read(8) != _MAGIC:
raise SyntaxError("not a PNG file") raise SyntaxError("not a PNG file")
self.__fp = self.fp self.__fp = self.fp
self.__frame = 0
# #
# Parse headers up to the first IDAT or fDAT chunk # Parse headers up to the first IDAT or fDAT chunk