From 8dbbce624f7ce9ad85eb50075d9e3dfdcb0fbfd4 Mon Sep 17 00:00:00 2001 From: Andrew Murray <radarhere@users.noreply.github.com> Date: Wed, 2 Apr 2025 12:16:25 +1100 Subject: [PATCH] Compare absolute path of filename --- src/PIL/Image.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index c62d7a8a3..807814c02 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -2543,7 +2543,9 @@ class Image: from . import ImageFile # may mutate self! - if isinstance(self, ImageFile.ImageFile) and filename == self.filename: + if isinstance(self, ImageFile.ImageFile) and os.path.abspath( + filename + ) == os.path.abspath(self.filename): self._ensure_mutable() else: self.load()