Removed methods deprecated in 2.0

This commit is contained in:
Andrew Murray 2015-07-13 17:41:53 +10:00
parent 47366692d9
commit baa5143394
4 changed files with 0 additions and 115 deletions

View File

@ -681,19 +681,6 @@ class Image(object):
return b"".join(data)
# Declare tostring as alias to tobytes
def tostring(self, *args, **kw):
"""Deprecated alias to tobytes.
.. deprecated:: 2.0
"""
warnings.warn(
'tostring() is deprecated. Please call tobytes() instead.',
DeprecationWarning,
stacklevel=2,
)
return self.tobytes(*args, **kw)
def tobitmap(self, name="image"):
"""
Returns the image converted to an X11 bitmap.
@ -741,16 +728,6 @@ class Image(object):
if s[1] != 0:
raise ValueError("cannot decode image data")
def fromstring(self, *args, **kw):
"""Deprecated alias to frombytes.
.. deprecated:: 2.0
"""
warnings.warn(
'fromstring() is deprecated. Please call frombytes() instead.',
DeprecationWarning)
return self.frombytes(*args, **kw)
def load(self):
"""
Allocates storage for the image and loads the pixel data. In
@ -1247,29 +1224,6 @@ class Image(object):
return self.im.histogram(extrema)
return self.im.histogram()
def offset(self, xoffset, yoffset=None):
"""
.. deprecated:: 2.0
.. note:: New code should use :py:func:`PIL.ImageChops.offset`.
Returns a copy of the image where the data has been offset by the given
distances. Data wraps around the edges. If **yoffset** is omitted, it
is assumed to be equal to **xoffset**.
:param xoffset: The horizontal distance.
:param yoffset: The vertical distance. If omitted, both
distances are set to the same value.
:returns: An :py:class:`~PIL.Image.Image` object.
"""
if warnings:
warnings.warn(
"'offset' is deprecated; use 'ImageChops.offset' instead",
DeprecationWarning, stacklevel=2
)
from PIL import ImageChops
return ImageChops.offset(self, xoffset, yoffset)
def paste(self, im, box=None, mask=None):
"""
Pastes another image into this image. The box argument is either
@ -2080,19 +2034,6 @@ def frombytes(mode, size, data, decoder_name="raw", *args):
return im
def fromstring(*args, **kw):
"""Deprecated alias to frombytes.
.. deprecated:: 2.0
"""
warnings.warn(
'fromstring() is deprecated. Please call frombytes() instead.',
DeprecationWarning,
stacklevel=2
)
return frombytes(*args, **kw)
def frombuffer(mode, size, data, decoder_name="raw", *args):
"""
Creates an image memory referencing pixel data in a byte buffer.

View File

@ -17,7 +17,6 @@
# See the README file for information on usage and redistribution.
#
import warnings
from PIL import Image
@ -183,25 +182,6 @@ class Dib(object):
"""
return self.image.tobytes()
##
# Deprecated aliases to frombytes & tobytes.
def fromstring(self, *args, **kw):
warnings.warn(
'fromstring() is deprecated. Please call frombytes() instead.',
DeprecationWarning,
stacklevel=2
)
return self.frombytes(*args, **kw)
def tostring(self):
warnings.warn(
'tostring() is deprecated. Please call tobytes() instead.',
DeprecationWarning,
stacklevel=2
)
return self.tobytes()
##
# Create a Window with the given title size.

View File

@ -1,25 +0,0 @@
from helper import unittest, PillowTestCase, hopper
class TestImageOffset(PillowTestCase):
def test_offset(self):
im1 = hopper()
im2 = self.assert_warning(DeprecationWarning, lambda: im1.offset(10))
self.assertEqual(im1.getpixel((0, 0)), im2.getpixel((10, 10)))
im2 = self.assert_warning(
DeprecationWarning, lambda: im1.offset(10, 20))
self.assertEqual(im1.getpixel((0, 0)), im2.getpixel((10, 20)))
im2 = self.assert_warning(
DeprecationWarning, lambda: im1.offset(20, 20))
self.assertEqual(im1.getpixel((0, 0)), im2.getpixel((20, 20)))
if __name__ == '__main__':
unittest.main()
# End of file

View File

@ -107,17 +107,6 @@ class TestImageWinDib(PillowTestCase):
# Confirm they're the same
self.assertEqual(dib1.tobytes(), dib2.tobytes())
def test_dib_fromstring_tostring_deprecated(self):
# Arrange
im = hopper()
dib = ImageWin.Dib(im)
test_buffer = dib.tobytes()
# Act/Assert
self.assert_warning(DeprecationWarning, dib.tostring)
self.assert_warning(DeprecationWarning,
lambda: dib.fromstring(test_buffer))
if __name__ == '__main__':
unittest.main()