Merge pull request #4798 from hugovk/rm-deprecated-notimplemented

Remove long-deprecated Image.py functions
This commit is contained in:
Andrew Murray 2020-07-24 20:48:20 +10:00 committed by GitHub
commit 11de331886
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 43 deletions

View File

@ -466,18 +466,6 @@ class TestImage:
with pytest.raises(ValueError): with pytest.raises(ValueError):
Image.core.fill("RGB", (2, -2), (0, 0, 0)) Image.core.fill("RGB", (2, -2), (0, 0, 0))
def test_offset_not_implemented(self):
# Arrange
with hopper() as im:
# Act / Assert
with pytest.raises(NotImplementedError):
im.offset(None)
def test_fromstring(self):
with pytest.raises(NotImplementedError):
Image.fromstring()
def test_linear_gradient_wrong_mode(self): def test_linear_gradient_wrong_mode(self):
# Arrange # Arrange
wrong_mode = "RGB" wrong_mode = "RGB"

View File

@ -1,4 +1,3 @@
import pytest
from PIL import Image from PIL import Image
from .helper import assert_image_equal, hopper from .helper import assert_image_equal, hopper
@ -9,8 +8,3 @@ def test_sanity():
im2 = Image.frombytes(im1.mode, im1.size, im1.tobytes()) im2 = Image.frombytes(im1.mode, im1.size, im1.tobytes())
assert_image_equal(im1, im2) assert_image_equal(im1, im2)
def test_not_implemented():
with pytest.raises(NotImplementedError):
Image.fromstring()

View File

@ -55,6 +55,33 @@ Removed features
Deprecated features are only removed in major releases after an appropriate Deprecated features are only removed in major releases after an appropriate
period of deprecation has passed. period of deprecation has passed.
im.offset
~~~~~~~~~
.. deprecated:: 1.1.2
.. versionremoved:: 8.0.0
``im.offset()`` has been removed, call ``ImageChops.offset()`` instead.
It was documented as deprecated in PIL 1.1.2,
raised a ``DeprecationWarning`` since 1.1.5,
an ``Exception`` since Pillow 3.0.0
and ``NotImplementedError`` since 3.3.0.
Image.fromstring, im.fromstring and im.tostring
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 2.0.0
.. versionremoved:: 8.0.0
* ``Image.fromstring()`` has been removed, call :py:func:`.Image.frombytes()` instead.
* ``im.fromstring()`` has been removed, call :py:meth:`~PIL.Image.Image.frombytes()` instead.
* ``im.tostring()`` has been removed, call :py:meth:`~PIL.Image.Image.tobytes()` instead.
They issued a ``DeprecationWarning`` since 2.0.0,
an ``Exception`` since 3.0.0
and ``NotImplementedError`` since 3.3.0.
ImageCms.CmsProfile attributes ImageCms.CmsProfile attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -160,6 +160,7 @@ This crops the input image with the provided coordinates:
.. automethod:: PIL.Image.Image.effect_spread .. automethod:: PIL.Image.Image.effect_spread
.. automethod:: PIL.Image.Image.entropy .. automethod:: PIL.Image.Image.entropy
.. automethod:: PIL.Image.Image.filter .. automethod:: PIL.Image.Image.filter
.. automethod:: PIL.Image.Image.frombytes
This blurs the input image using a filter from the ``ImageFilter`` module: This blurs the input image using a filter from the ``ImageFilter`` module:
@ -204,7 +205,6 @@ This helps to get the bounding box coordinates of the input image:
.. automethod:: PIL.Image.Image.getpixel .. automethod:: PIL.Image.Image.getpixel
.. automethod:: PIL.Image.Image.getprojection .. automethod:: PIL.Image.Image.getprojection
.. automethod:: PIL.Image.Image.histogram .. automethod:: PIL.Image.Image.histogram
.. automethod:: PIL.Image.Image.offset
.. automethod:: PIL.Image.Image.paste .. automethod:: PIL.Image.Image.paste
.. automethod:: PIL.Image.Image.point .. automethod:: PIL.Image.Image.point
.. automethod:: PIL.Image.Image.putalpha .. automethod:: PIL.Image.Image.putalpha
@ -251,7 +251,6 @@ This rotates the input image by ``theta`` degrees counter clockwise:
.. automethod:: PIL.Image.Image.thumbnail .. automethod:: PIL.Image.Image.thumbnail
.. automethod:: PIL.Image.Image.tobitmap .. automethod:: PIL.Image.Image.tobitmap
.. automethod:: PIL.Image.Image.tobytes .. automethod:: PIL.Image.Image.tobytes
.. automethod:: PIL.Image.Image.tostring
.. automethod:: PIL.Image.Image.transform .. automethod:: PIL.Image.Image.transform
.. automethod:: PIL.Image.Image.transpose .. automethod:: PIL.Image.Image.transpose
@ -271,8 +270,6 @@ This flips the input image by using the :data:`FLIP_LEFT_RIGHT` method.
.. automethod:: PIL.Image.Image.verify .. automethod:: PIL.Image.Image.verify
.. automethod:: PIL.Image.Image.fromstring
.. automethod:: PIL.Image.Image.load .. automethod:: PIL.Image.Image.load
.. automethod:: PIL.Image.Image.close .. automethod:: PIL.Image.Image.close

View File

@ -746,11 +746,6 @@ class Image:
return b"".join(data) return b"".join(data)
def tostring(self, *args, **kw):
raise NotImplementedError(
"tostring() has been removed. Please call tobytes() instead."
)
def tobitmap(self, name="image"): def tobitmap(self, name="image"):
""" """
Returns the image converted to an X11 bitmap. Returns the image converted to an X11 bitmap.
@ -802,11 +797,6 @@ class Image:
if s[1] != 0: if s[1] != 0:
raise ValueError("cannot decode image data") raise ValueError("cannot decode image data")
def fromstring(self, *args, **kw):
raise NotImplementedError(
"fromstring() has been removed. Please call frombytes() instead."
)
def load(self): def load(self):
""" """
Allocates storage for the image and loads the pixel data. In Allocates storage for the image and loads the pixel data. In
@ -1434,11 +1424,6 @@ class Image:
return self.im.entropy(extrema) return self.im.entropy(extrema)
return self.im.entropy() return self.im.entropy()
def offset(self, xoffset, yoffset=None):
raise NotImplementedError(
"offset() has been removed. Please call ImageChops.offset() instead."
)
def paste(self, im, box=None, mask=None): def paste(self, im, box=None, mask=None):
""" """
Pastes another image into this image. The box argument is either Pastes another image into this image. The box argument is either
@ -2672,12 +2657,6 @@ def frombytes(mode, size, data, decoder_name="raw", *args):
return im return im
def fromstring(*args, **kw):
raise NotImplementedError(
"fromstring() has been removed. Please call frombytes() instead."
)
def frombuffer(mode, size, data, decoder_name="raw", *args): def frombuffer(mode, size, data, decoder_name="raw", *args):
""" """
Creates an image memory referencing pixel data in a byte buffer. Creates an image memory referencing pixel data in a byte buffer.