Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Raise DeprecationWarning on raise_ioerror #48

Merged
merged 3 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Tests/test_imagefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ def test_safeblock(self):

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)
Expand Down
9 changes: 9 additions & 0 deletions docs/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ Deprecated features
Below are features which are considered deprecated. Where appropriate,
a ``DeprecationWarning`` is issued.

ImageFile.raise_ioerror
~~~~~~~~~~~~~~~~~~~~~~~

.. deprecated:: 7.2.0

``IOError`` was merged into ``OSError`` in Python 3.3. So, ``ImageFile.raise_ioerror``
is now deprecated and will be removed in a future released. Use
``ImageFile.raise_oserror`` instead.

PILLOW_VERSION constant
~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
10 changes: 10 additions & 0 deletions src/PIL/ImageFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io
import struct
import sys
import warnings

from . import Image
from ._util import isPath
Expand Down Expand Up @@ -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]
Expand Down