From e8029df7f1642278654cc1163cc6c4b4ec1d18e2 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 9 Sep 2024 23:25:46 +1000 Subject: [PATCH] Use hasattr --- src/PIL/Image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 45f01917b13..5e5b54e34ac 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -604,7 +604,7 @@ def __enter__(self): return self def _close_fp(self): - if getattr(self, "_fp", False): + if hasattr(self, "_fp"): if self._fp != self.fp: self._fp.close() self._fp = DeferredError(ValueError("Operation on closed image"))