Skip to content

Conversation

@radarhere
Copy link
Member

@radarhere radarhere commented Sep 9, 2025

Pillow/src/PIL/Image.py

Lines 2073 to 2075 in b7e0570

if self.readonly:
self._copy()
self.load()

and
im.load()
if im.readonly:
im._copy() # make it writeable

are virtually identical to

Pillow/src/PIL/Image.py

Lines 629 to 633 in b7e0570

def _ensure_mutable(self) -> None:
if self.readonly:
self._copy()
else:
self.load()

So they can be replaced with calls to _ensure_mutable()

@hugovk hugovk merged commit 6b4bb79 into python-pillow:main Oct 8, 2025
51 checks passed
@radarhere radarhere deleted the ensure_mutable branch October 8, 2025 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants