From c952134e0069cdf61edcc212a21450a1730240a3 Mon Sep 17 00:00:00 2001 From: "Brian J. Crowell" Date: Thu, 8 Nov 2012 22:59:38 -0600 Subject: [PATCH] py3k: Issue warnings when using the old fromstring/tostring ...although, you have to turn on deprecation warnings specifically in order to get them. --- PIL/Image.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index 2f2eac3b4..b2b5d2493 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -540,7 +540,9 @@ class Image: if bytes is str: # Declare tostring as alias to tobytes - tostring = tobytes + def tostring(self, *args, **kw): + warnings.warn('tostring() is deprecated. Please call tobytes() instead.', DeprecationWarning) + return self.tobytes(*args, **kw) ## # Returns the image converted to an X11 bitmap. This method @@ -591,7 +593,9 @@ class Image: if bytes is str: # Declare fromstring as alias to frombytes - fromstring = frombytes + def fromstring(self, *args, **kw): + warnings.warn('fromstring() is deprecated. Please call frombytes() instead.', DeprecationWarning) + return self.frombytes(*args, **kw) ## # Allocates storage for the image and loads the pixel data. In @@ -1804,7 +1808,9 @@ def frombytes(mode, size, data, decoder_name="raw", *args): if bytes is str: # Declare fromstring as an alias for frombytes - fromstring = frombytes + def fromstring(*args, **kw): + warnings.warn('fromstring() is deprecated. Please call frombytes() instead.', DeprecationWarning) + return frombytes(*args, **kw) ## # (New in 1.1.4) Creates an image memory referencing pixel data in a