mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 01:04:29 +03:00
Fixed bug in saving to fp-objects in Python >= 3.4
This commit is contained in:
parent
2a74940817
commit
38fd77ca7d
|
@ -1659,7 +1659,7 @@ class Image(object):
|
|||
if isinstance(fp, Path):
|
||||
filename = str(fp)
|
||||
open_fp = True
|
||||
elif hasattr(fp, "name") and isPath(fp.name):
|
||||
if not filename and hasattr(fp, "name") and isPath(fp.name):
|
||||
# only set the name for metadata purposes
|
||||
filename = fp.name
|
||||
|
||||
|
|
|
@ -63,6 +63,18 @@ class TestImage(PillowTestCase):
|
|||
os.remove(temp_file)
|
||||
im.save(Path(temp_file))
|
||||
|
||||
def test_fp_name(self):
|
||||
temp_file = self.tempfile("temp.jpg")
|
||||
|
||||
class FP(object):
|
||||
def write(a, b):
|
||||
pass
|
||||
fp = FP()
|
||||
fp.name = temp_file
|
||||
|
||||
im = hopper()
|
||||
im.save(fp)
|
||||
|
||||
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