mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-06 06:03:14 +03:00
Merge pull request #229 from wiredfool/warnings
Fixing and Suppressing warnings revealed in #227
This commit is contained in:
commit
aad417dcbe
|
@ -47,7 +47,11 @@ class ImagePalette:
|
||||||
raise ValueError("palette contains raw palette data")
|
raise ValueError("palette contains raw palette data")
|
||||||
if isinstance(self.palette, bytes):
|
if isinstance(self.palette, bytes):
|
||||||
return self.palette
|
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
|
# Declare tostring as an alias for tobytes
|
||||||
tostring = tobytes
|
tostring = tobytes
|
||||||
|
|
|
@ -45,5 +45,10 @@ def test_path():
|
||||||
assert_equal(list(p), [(0.0, 1.0)])
|
assert_equal(list(p), [(0.0, 1.0)])
|
||||||
p = ImagePath.Path(array.array("f", [0, 1]))
|
p = ImagePath.Path(array.array("f", [0, 1]))
|
||||||
assert_equal(list(p), [(0.0, 1.0)])
|
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)])
|
assert_equal(list(p), [(0.0, 1.0)])
|
||||||
|
|
|
@ -3,6 +3,15 @@ from __future__ import print_function
|
||||||
# require that deprecation warnings are triggered
|
# require that deprecation warnings are triggered
|
||||||
import warnings
|
import warnings
|
||||||
warnings.simplefilter('default')
|
warnings.simplefilter('default')
|
||||||
|
# temporarily turn off resource warnings that warn about unclosed
|
||||||
|
# files in the test scripts.
|
||||||
|
try:
|
||||||
|
warnings.filterwarnings("ignore", category=ResourceWarning)
|
||||||
|
except NameError:
|
||||||
|
# we expect a NameError on py2.x, since it doesn't have ResourceWarnings.
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
py3 = (sys.version_info >= (3,0))
|
py3 = (sys.version_info >= (3,0))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user