better warning messages for fromstring/tostring

This commit is contained in:
Mikhail Korobov 2013-02-26 16:19:35 +06:00
parent fbcc9b5c77
commit aacb8097c3

View File

@ -541,7 +541,11 @@ class Image:
if bytes is str:
# Declare tostring as alias to tobytes
def tostring(self, *args, **kw):
warnings.warn('tostring() is deprecated. Please call tobytes() instead.', DeprecationWarning)
warnings.warn(
'tostring() is deprecated. Please call tobytes() instead.',
DeprecationWarning,
stacklevel=2,
)
return self.tobytes(*args, **kw)
##
@ -1809,7 +1813,11 @@ def frombytes(mode, size, data, decoder_name="raw", *args):
if bytes is str:
# Declare fromstring as an alias for frombytes
def fromstring(*args, **kw):
warnings.warn('fromstring() is deprecated. Please call frombytes() instead.', DeprecationWarning)
warnings.warn(
'fromstring() is deprecated. Please call frombytes() instead.',
DeprecationWarning,
stacklevel=2
)
return frombytes(*args, **kw)
##