mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Merge pull request #1748 from radarhere/path
Fixed bug when saving to a non-existent path using pathlib
This commit is contained in:
commit
fb853267f9
|
@ -1646,7 +1646,7 @@ class Image(object):
|
|||
elif sys.version_info >= (3, 4):
|
||||
from pathlib import Path
|
||||
if isinstance(fp, Path):
|
||||
filename = str(fp.resolve())
|
||||
filename = str(fp)
|
||||
open_fp = True
|
||||
elif hasattr(fp, "name") and isPath(fp.name):
|
||||
# only set the name for metadata purposes
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from helper import unittest, PillowTestCase, hopper
|
||||
|
||||
from PIL import Image
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
|
@ -57,6 +58,11 @@ class TestImage(PillowTestCase):
|
|||
self.assertEqual(im.mode, "RGB")
|
||||
self.assertEqual(im.size, (128, 128))
|
||||
|
||||
temp_file = self.tempfile("temp.jpg")
|
||||
if os.path.exists(temp_file):
|
||||
os.remove(temp_file)
|
||||
im.save(Path(temp_file))
|
||||
|
||||
def test_tempfile(self):
|
||||
# see #1460, pathlib support breaks tempfile.TemporaryFile on py27
|
||||
# Will error out on save on 3.0.0
|
||||
|
|
Loading…
Reference in New Issue
Block a user