mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-26 17:24:31 +03:00
Restored deprecated methods with errors instead
This commit is contained in:
parent
5835c1e09c
commit
71c95c8e5f
17
PIL/Image.py
17
PIL/Image.py
|
@ -681,6 +681,10 @@ class Image(object):
|
|||
|
||||
return b"".join(data)
|
||||
|
||||
def tostring(self, *args, **kw):
|
||||
raise Exception("tostring() has been removed. " +
|
||||
"Please call tobytes() instead.")
|
||||
|
||||
def tobitmap(self, name="image"):
|
||||
"""
|
||||
Returns the image converted to an X11 bitmap.
|
||||
|
@ -728,6 +732,10 @@ class Image(object):
|
|||
if s[1] != 0:
|
||||
raise ValueError("cannot decode image data")
|
||||
|
||||
def fromstring(self, *args, **kw):
|
||||
raise Exception("fromstring() has been removed. " +
|
||||
"Please call frombytes() instead.")
|
||||
|
||||
def load(self):
|
||||
"""
|
||||
Allocates storage for the image and loads the pixel data. In
|
||||
|
@ -1224,6 +1232,10 @@ class Image(object):
|
|||
return self.im.histogram(extrema)
|
||||
return self.im.histogram()
|
||||
|
||||
def offset(self, xoffset, yoffset=None):
|
||||
raise Exception("offset() has been removed. " +
|
||||
"Please call ImageChops.offset() instead.")
|
||||
|
||||
def paste(self, im, box=None, mask=None):
|
||||
"""
|
||||
Pastes another image into this image. The box argument is either
|
||||
|
@ -2034,6 +2046,11 @@ def frombytes(mode, size, data, decoder_name="raw", *args):
|
|||
return im
|
||||
|
||||
|
||||
def fromstring(*args, **kw):
|
||||
raise Exception("fromstring() has been removed. " +
|
||||
"Please call frombytes() instead.")
|
||||
|
||||
|
||||
def frombuffer(mode, size, data, decoder_name="raw", *args):
|
||||
"""
|
||||
Creates an image memory referencing pixel data in a byte buffer.
|
||||
|
|
|
@ -90,6 +90,14 @@ class ImageDraw(object):
|
|||
self.fill = 0
|
||||
self.font = None
|
||||
|
||||
def setink(self, ink):
|
||||
raise Exception("setink() has been removed. " +
|
||||
"Please use keyword arguments instead.")
|
||||
|
||||
def setfill(self, onoff):
|
||||
raise Exception("setfill() has been removed. " +
|
||||
"Please use keyword arguments instead.")
|
||||
|
||||
def setfont(self, font):
|
||||
if warnings:
|
||||
warnings.warn("setfont() is deprecated. " +
|
||||
|
|
|
@ -182,6 +182,14 @@ class Dib(object):
|
|||
"""
|
||||
return self.image.tobytes()
|
||||
|
||||
def fromstring(self, *args, **kw):
|
||||
raise Exception("fromstring() has been removed. " +
|
||||
"Please use frombytes() instead.")
|
||||
|
||||
def tostring(self, *args, **kw):
|
||||
raise Exception("tostring() has been removed. " +
|
||||
"Please use tobytes() instead.")
|
||||
|
||||
|
||||
##
|
||||
# Create a Window with the given title size.
|
||||
|
|
|
@ -44,6 +44,14 @@ class TestImageDraw(PillowTestCase):
|
|||
draw.polygon(list(range(100)))
|
||||
draw.rectangle(list(range(4)))
|
||||
|
||||
def test_removed_methods(self):
|
||||
im = hopper()
|
||||
|
||||
draw = ImageDraw.Draw(im)
|
||||
|
||||
self.assertRaises(Exception, lambda: draw.setink(0))
|
||||
self.assertRaises(Exception, lambda: draw.setfill(0))
|
||||
|
||||
def test_mode_mismatch(self):
|
||||
im = hopper("RGB").copy()
|
||||
|
||||
|
|
|
@ -107,6 +107,15 @@ class TestImageWinDib(PillowTestCase):
|
|||
# Confirm they're the same
|
||||
self.assertEqual(dib1.tobytes(), dib2.tobytes())
|
||||
|
||||
def test_removed_methods(self):
|
||||
# Arrange
|
||||
im = hopper()
|
||||
dib = ImageWin.Dib(im)
|
||||
|
||||
# Act/Assert
|
||||
self.assertRaises(Exception, dib.tostring)
|
||||
self.assertRaises(Exception, lambda: dib.fromstring(test_buffer))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user