Merge pull request #5633 from radarhere/save_path

Corrected pathlib.Path detection when saving
This commit is contained in:
Hugo van Kemenade 2021-08-06 17:15:15 +03:00 committed by GitHub
commit 2e5ce839ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View File

@ -149,10 +149,11 @@ class TestImage:
assert im.mode == "RGB"
assert im.size == (128, 128)
temp_file = str(tmp_path / "temp.jpg")
if os.path.exists(temp_file):
os.remove(temp_file)
im.save(Path(temp_file))
for ext in (".jpg", ".jp2"):
temp_file = str(tmp_path / ("temp." + ext))
if os.path.exists(temp_file):
os.remove(temp_file)
im.save(Path(temp_file))
def test_fp_name(self, tmp_path):
temp_file = str(tmp_path / "temp.jpg")

View File

@ -2180,12 +2180,12 @@ class Image:
filename = ""
open_fp = False
if isPath(fp):
filename = fp
open_fp = True
elif isinstance(fp, Path):
if isinstance(fp, Path):
filename = str(fp)
open_fp = True
elif isPath(fp):
filename = fp
open_fp = True
elif fp == sys.stdout:
try:
fp = sys.stdout.buffer