mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-03 19:45:56 +03:00
Merge pull request #2227 from radarhere/fpname
Fixed bug in saving to fp-objects in Python >= 3.4
This commit is contained in:
commit
87b8d2894a
|
@ -1659,7 +1659,7 @@ class Image(object):
|
||||||
if isinstance(fp, Path):
|
if isinstance(fp, Path):
|
||||||
filename = str(fp)
|
filename = str(fp)
|
||||||
open_fp = True
|
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
|
# only set the name for metadata purposes
|
||||||
filename = fp.name
|
filename = fp.name
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,18 @@ class TestImage(PillowTestCase):
|
||||||
os.remove(temp_file)
|
os.remove(temp_file)
|
||||||
im.save(Path(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):
|
def test_tempfile(self):
|
||||||
# see #1460, pathlib support breaks tempfile.TemporaryFile on py27
|
# see #1460, pathlib support breaks tempfile.TemporaryFile on py27
|
||||||
# Will error out on save on 3.0.0
|
# Will error out on save on 3.0.0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user