Added return type to ImageFile _close_fp() (#9356)

This commit is contained in:
Andrew Murray 2025-12-31 23:47:50 +11:00 committed by GitHub
parent 19910ed03e
commit 2ebfe30ae3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -131,6 +131,7 @@ class ImageFile(Image.Image):
self.decoderconfig: tuple[Any, ...] = ()
self.decodermaxblock = MAXBLOCK
self._fp: IO[bytes] | DeferredError
if is_path(fp):
# filename
self.fp = open(fp, "rb")
@ -167,7 +168,7 @@ class ImageFile(Image.Image):
def _open(self) -> None:
pass
def _close_fp(self):
def _close_fp(self) -> None:
if getattr(self, "_fp", False) and not isinstance(self._fp, DeferredError):
if self._fp != self.fp:
self._fp.close()