mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Corrected pathlib.Path detection when saving
This commit is contained in:
parent
68c5f2dce1
commit
4038a287ee
|
@ -149,10 +149,11 @@ class TestImage:
|
||||||
assert im.mode == "RGB"
|
assert im.mode == "RGB"
|
||||||
assert im.size == (128, 128)
|
assert im.size == (128, 128)
|
||||||
|
|
||||||
temp_file = str(tmp_path / "temp.jpg")
|
for ext in (".jpg", ".jp2"):
|
||||||
if os.path.exists(temp_file):
|
temp_file = str(tmp_path / ("temp." + ext))
|
||||||
os.remove(temp_file)
|
if os.path.exists(temp_file):
|
||||||
im.save(Path(temp_file))
|
os.remove(temp_file)
|
||||||
|
im.save(Path(temp_file))
|
||||||
|
|
||||||
def test_fp_name(self, tmp_path):
|
def test_fp_name(self, tmp_path):
|
||||||
temp_file = str(tmp_path / "temp.jpg")
|
temp_file = str(tmp_path / "temp.jpg")
|
||||||
|
|
|
@ -2180,12 +2180,12 @@ class Image:
|
||||||
|
|
||||||
filename = ""
|
filename = ""
|
||||||
open_fp = False
|
open_fp = False
|
||||||
if isPath(fp):
|
if isinstance(fp, Path):
|
||||||
filename = fp
|
|
||||||
open_fp = True
|
|
||||||
elif isinstance(fp, Path):
|
|
||||||
filename = str(fp)
|
filename = str(fp)
|
||||||
open_fp = True
|
open_fp = True
|
||||||
|
elif isPath(fp):
|
||||||
|
filename = fp
|
||||||
|
open_fp = True
|
||||||
elif fp == sys.stdout:
|
elif fp == sys.stdout:
|
||||||
try:
|
try:
|
||||||
fp = sys.stdout.buffer
|
fp = sys.stdout.buffer
|
||||||
|
|
Loading…
Reference in New Issue
Block a user