mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-24 08:14:10 +03:00
Merge pull request #4885 from radarhere/exception
This commit is contained in:
commit
572259bcde
|
@ -244,3 +244,8 @@ class TestPyDecoder:
|
||||||
im = MockImageFile(buf)
|
im = MockImageFile(buf)
|
||||||
assert im.format is None
|
assert im.format is None
|
||||||
assert im.get_format_mimetype() is None
|
assert im.get_format_mimetype() is None
|
||||||
|
|
||||||
|
def test_oserror(self):
|
||||||
|
im = Image.new("RGB", (1, 1))
|
||||||
|
with pytest.raises(OSError):
|
||||||
|
im.save(BytesIO(), "JPEG2000")
|
||||||
|
|
|
@ -509,7 +509,7 @@ def _save(im, fp, tile, bufsize=0):
|
||||||
try:
|
try:
|
||||||
fh = fp.fileno()
|
fh = fp.fileno()
|
||||||
fp.flush()
|
fp.flush()
|
||||||
except (AttributeError, io.UnsupportedOperation) as e:
|
except (AttributeError, io.UnsupportedOperation) as exc:
|
||||||
# compress to Python file-compatible object
|
# compress to Python file-compatible object
|
||||||
for e, b, o, a in tile:
|
for e, b, o, a in tile:
|
||||||
e = Image._getencoder(im.mode, e, a, im.encoderconfig)
|
e = Image._getencoder(im.mode, e, a, im.encoderconfig)
|
||||||
|
@ -526,7 +526,7 @@ def _save(im, fp, tile, bufsize=0):
|
||||||
if s:
|
if s:
|
||||||
break
|
break
|
||||||
if s < 0:
|
if s < 0:
|
||||||
raise OSError("encoder error %d when writing image file" % s) from e
|
raise OSError("encoder error %d when writing image file" % s) from exc
|
||||||
e.cleanup()
|
e.cleanup()
|
||||||
else:
|
else:
|
||||||
# slight speedup: compress to real file object
|
# slight speedup: compress to real file object
|
||||||
|
|
Loading…
Reference in New Issue
Block a user