mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
fixed deprecation warnings for tostring on array.array
This commit is contained in:
parent
94d9218dd0
commit
2322619372
|
@ -47,7 +47,11 @@ class ImagePalette:
|
|||
raise ValueError("palette contains raw palette data")
|
||||
if isinstance(self.palette, bytes):
|
||||
return self.palette
|
||||
return array.array("B", self.palette).tostring()
|
||||
arr = array.array("B", self.palette)
|
||||
if hasattr(arr, 'tobytes'):
|
||||
#py3k has a tobytes, tostring is deprecated.
|
||||
return arr.tobytes()
|
||||
return arr.tostring()
|
||||
|
||||
# Declare tostring as an alias for tobytes
|
||||
tostring = tobytes
|
||||
|
|
|
@ -45,5 +45,10 @@ def test_path():
|
|||
assert_equal(list(p), [(0.0, 1.0)])
|
||||
p = ImagePath.Path(array.array("f", [0, 1]))
|
||||
assert_equal(list(p), [(0.0, 1.0)])
|
||||
p = ImagePath.Path(array.array("f", [0, 1]).tostring())
|
||||
|
||||
arr = array.array("f", [0, 1])
|
||||
if hasattr(arr, 'tobytes'):
|
||||
p = ImagePath.Path(arr.tobytes())
|
||||
else:
|
||||
p = ImagePath.Path(arr.tostring())
|
||||
assert_equal(list(p), [(0.0, 1.0)])
|
||||
|
|
Loading…
Reference in New Issue
Block a user