Raise DeprecationWarning on raise_ioerror

This commit is contained in:
Andrew Murray 2020-04-07 19:53:35 +10:00 committed by Hugo
parent dda6145fce
commit 7bb51a4aca
2 changed files with 15 additions and 0 deletions

View File

@ -93,6 +93,11 @@ class TestImageFile:
assert_image_equal(im1, im2)
def test_raise_ioerror(self):
with pytest.raises(IOError):
with pytest.raises(DeprecationWarning):
ImageFile.raise_ioerror(1)
def test_raise_oserror(self):
with pytest.raises(OSError):
ImageFile.raise_oserror(1)

View File

@ -30,6 +30,7 @@
import io
import struct
import sys
import warnings
from . import Image
from ._util import isPath
@ -64,6 +65,15 @@ def raise_oserror(error):
raise OSError(message + " when reading image file")
def raise_ioerror(error):
warnings.warn(
"raise_ioerror is deprecated and will be removed in a future release. "
"Use raise_oserror instead.",
DeprecationWarning,
)
return raise_oserror(error)
def _tilesort(t):
# sort on offset
return t[2]