Skip to content

Commit 6b4bb79

Browse files
authored
Use _ensure_mutable() (#9200)
2 parents 797d83f + 3a580e0 commit 6b4bb79

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/PIL/Image.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,9 +2070,7 @@ def putpixel(
20702070
:param value: The pixel value.
20712071
"""
20722072

2073-
if self.readonly:
2074-
self._copy()
2075-
self.load()
2073+
self._ensure_mutable()
20762074

20772075
if (
20782076
self.mode in ("P", "PA")

src/PIL/ImageDraw.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ def __init__(self, im: Image.Image, mode: str | None = None) -> None:
7676
must be the same as the image mode. If omitted, the mode
7777
defaults to the mode of the image.
7878
"""
79-
im.load()
80-
if im.readonly:
81-
im._copy() # make it writeable
79+
im._ensure_mutable()
8280
blend = 0
8381
if mode is None:
8482
mode = im.mode

0 commit comments

Comments
 (0)