Skip to content

Commit 7bb51a4

Browse files
radarherehugovk
authored andcommitted
Raise DeprecationWarning on raise_ioerror
1 parent dda6145 commit 7bb51a4

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

Tests/test_imagefile.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ def test_safeblock(self):
9393

9494
assert_image_equal(im1, im2)
9595

96+
def test_raise_ioerror(self):
97+
with pytest.raises(IOError):
98+
with pytest.raises(DeprecationWarning):
99+
ImageFile.raise_ioerror(1)
100+
96101
def test_raise_oserror(self):
97102
with pytest.raises(OSError):
98103
ImageFile.raise_oserror(1)

src/PIL/ImageFile.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io
3131
import struct
3232
import sys
33+
import warnings
3334

3435
from . import Image
3536
from ._util import isPath
@@ -64,6 +65,15 @@ def raise_oserror(error):
6465
raise OSError(message + " when reading image file")
6566

6667

68+
def raise_ioerror(error):
69+
warnings.warn(
70+
"raise_ioerror is deprecated and will be removed in a future release. "
71+
"Use raise_oserror instead.",
72+
DeprecationWarning,
73+
)
74+
return raise_oserror(error)
75+
76+
6777
def _tilesort(t):
6878
# sort on offset
6979
return t[2]

0 commit comments

Comments
 (0)