Use _ensure_mutable() (#9200)

This commit is contained in:
Hugo van Kemenade 2025-10-08 19:22:04 +03:00 committed by GitHub
commit 6b4bb79b44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 6 deletions

View File

@ -2070,9 +2070,7 @@ class Image:
:param value: The pixel value.
"""
if self.readonly:
self._copy()
self.load()
self._ensure_mutable()
if (
self.mode in ("P", "PA")

View File

@ -76,9 +76,7 @@ class ImageDraw:
must be the same as the image mode. If omitted, the mode
defaults to the mode of the image.
"""
im.load()
if im.readonly:
im._copy() # make it writeable
im._ensure_mutable()
blend = 0
if mode is None:
mode = im.mode