mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-07 19:04:13 +03:00
Merge pull request #8852 from radarhere/save
Only change readonly if saved filename matches opened filename
This commit is contained in:
commit
64178415e6
|
@ -258,6 +258,15 @@ class TestImage:
|
|||
assert im.readonly
|
||||
im.save(temp_file)
|
||||
|
||||
def test_save_without_changing_readonly(self, tmp_path: Path) -> None:
|
||||
temp_file = tmp_path / "temp.bmp"
|
||||
|
||||
with Image.open("Tests/images/rgb32bf-rgba.bmp") as im:
|
||||
assert im.readonly
|
||||
|
||||
im.save(temp_file)
|
||||
assert im.readonly
|
||||
|
||||
def test_dump(self, tmp_path: Path) -> None:
|
||||
im = Image.new("L", (10, 10))
|
||||
im._dump(str(tmp_path / "temp_L.ppm"))
|
||||
|
|
|
@ -2540,8 +2540,13 @@ class Image:
|
|||
msg = f"unknown file extension: {ext}"
|
||||
raise ValueError(msg) from e
|
||||
|
||||
from . import ImageFile
|
||||
|
||||
# may mutate self!
|
||||
self._ensure_mutable()
|
||||
if isinstance(self, ImageFile.ImageFile) and filename == self.filename:
|
||||
self._ensure_mutable()
|
||||
else:
|
||||
self.load()
|
||||
|
||||
save_all = params.pop("save_all", None)
|
||||
self.encoderinfo = {**getattr(self, "encoderinfo", {}), **params}
|
||||
|
|
Loading…
Reference in New Issue
Block a user