Skip to content

Commit

Permalink
Do not attempt to close a DeferredError
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 22, 2024
1 parent e8029df commit 5833f1a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def __enter__(self):
return self

def _close_fp(self):
if hasattr(self, "_fp"):
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"))
Expand Down

0 comments on commit 5833f1a

Please sign in to comment.