Use hasattr

This commit is contained in:
Andrew Murray 2024-09-09 23:25:46 +10:00
parent e005bcf8f2
commit 957db67d43

View File

@ -173,8 +173,8 @@ class ImageFile(Image.Image):
return self
def _close_fp(self) -> None:
if getattr(self, "_fp", False):
if self._fp != self.fp and not isinstance(self._fp, DeferredError):
if hasattr(self, "_fp") and not isinstance(self._fp, DeferredError):
if self._fp != self.fp:
self._fp.close()
self._fp = DeferredError(ValueError("Operation on closed image"))
if self.fp: