Simplify code by using _accept

This commit is contained in:
Andrew Murray 2022-02-26 17:53:27 +11:00
parent e2288356ca
commit 56324c300d
2 changed files with 2 additions and 2 deletions

View File

@ -167,7 +167,7 @@ class IcnsFile:
self.dct = dct = {}
self.fobj = fobj
sig, filesize = nextheader(fobj)
if sig != MAGIC:
if not _accept(sig):
raise SyntaxError("not an icns file")
i = HEADERSIZE
while i < filesize:

View File

@ -493,7 +493,7 @@ class ImageFileDirectory_v2(MutableMapping):
endianness.
:param prefix: Override the endianness of the file.
"""
if ifh[:4] not in PREFIXES:
if not _accept(ifh):
raise SyntaxError(f"not a TIFF file (header {repr(ifh)} not valid)")
self._prefix = prefix if prefix is not None else ifh[:2]
if self._prefix == MM: