mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Deprecate ImagePalette size parameter
This commit is contained in:
parent
3462b5fd74
commit
41b968ad10
|
@ -10,8 +10,9 @@ def test_sanity():
|
||||||
palette = ImagePalette.ImagePalette("RGB", list(range(256)) * 3)
|
palette = ImagePalette.ImagePalette("RGB", list(range(256)) * 3)
|
||||||
assert len(palette.colors) == 256
|
assert len(palette.colors) == 256
|
||||||
|
|
||||||
with pytest.raises(ValueError):
|
with pytest.warns(DeprecationWarning):
|
||||||
ImagePalette.ImagePalette("RGB", list(range(256)) * 3, 10)
|
with pytest.raises(ValueError):
|
||||||
|
ImagePalette.ImagePalette("RGB", list(range(256)) * 3, 10)
|
||||||
|
|
||||||
|
|
||||||
def test_reload():
|
def test_reload():
|
||||||
|
|
|
@ -92,6 +92,17 @@ dictionary. The :py:attr:`~PIL.JpegImagePlugin.convert_dict_qtables` method no l
|
||||||
performs any operations on the data given to it, has been deprecated and will be
|
performs any operations on the data given to it, has been deprecated and will be
|
||||||
removed in Pillow 10.0.0 (2023-01-02).
|
removed in Pillow 10.0.0 (2023-01-02).
|
||||||
|
|
||||||
|
ImagePalette size parameter
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. deprecated:: 8.4.0
|
||||||
|
|
||||||
|
The ``size`` parameter will be removed in Pillow 10.0.0 (2023-01-02).
|
||||||
|
|
||||||
|
Before Pillow 8.3.0, ImagePalette required palette data of particular lengths by
|
||||||
|
default, and the size parameter could be used to override that. Pillow 8.3.0 removed
|
||||||
|
the default required length, also removing the need for the size parameter.
|
||||||
|
|
||||||
Removed features
|
Removed features
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import array
|
import array
|
||||||
|
import warnings
|
||||||
|
|
||||||
from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile
|
from . import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile
|
||||||
|
|
||||||
|
@ -40,8 +41,14 @@ class ImagePalette:
|
||||||
self.rawmode = None # if set, palette contains raw data
|
self.rawmode = None # if set, palette contains raw data
|
||||||
self.palette = palette or bytearray()
|
self.palette = palette or bytearray()
|
||||||
self.dirty = None
|
self.dirty = None
|
||||||
if size != 0 and size != len(self.palette):
|
if size != 0:
|
||||||
raise ValueError("wrong palette size")
|
warnings.warn(
|
||||||
|
"The size parameter is deprecated and will be removed in Pillow 10 "
|
||||||
|
"(2023-01-02).",
|
||||||
|
DeprecationWarning,
|
||||||
|
)
|
||||||
|
if size != len(self.palette):
|
||||||
|
raise ValueError("wrong palette size")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def palette(self):
|
def palette(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user