mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 02:06:18 +03:00
add check for deprecated rawmodes when creating an ImagePalette
This commit is contained in:
parent
976f30709a
commit
75e54c23ac
|
@ -158,6 +158,12 @@ def test_rawmode_valueerrors(tmp_path: Path) -> None:
|
||||||
palette.save(f)
|
palette.save(f)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("rawmode", Image._DEPRECATED_RAWMODES)
|
||||||
|
def test_rawmode_deprecated(rawmode: str) -> None:
|
||||||
|
with pytest.warns(DeprecationWarning):
|
||||||
|
ImagePalette.raw(rawmode, b"")
|
||||||
|
|
||||||
|
|
||||||
def test_getdata() -> None:
|
def test_getdata() -> None:
|
||||||
# Arrange
|
# Arrange
|
||||||
data_in = list(range(256)) * 3
|
data_in = list(range(256)) * 3
|
||||||
|
|
|
@ -209,6 +209,16 @@ class ImagePalette:
|
||||||
|
|
||||||
|
|
||||||
def raw(rawmode: str, data: Sequence[int] | bytes | bytearray) -> ImagePalette:
|
def raw(rawmode: str, data: Sequence[int] | bytes | bytearray) -> ImagePalette:
|
||||||
|
from . import Image
|
||||||
|
from ._deprecate import deprecate
|
||||||
|
|
||||||
|
if rawmode in Image._DEPRECATED_RAWMODES:
|
||||||
|
deprecate(
|
||||||
|
f"rawmode {rawmode}",
|
||||||
|
12,
|
||||||
|
replacement=f"rawmode {Image._DEPRECATED_RAWMODES[rawmode]}",
|
||||||
|
)
|
||||||
|
|
||||||
palette = ImagePalette()
|
palette = ImagePalette()
|
||||||
palette.rawmode = rawmode
|
palette.rawmode = rawmode
|
||||||
palette.palette = data
|
palette.palette = data
|
||||||
|
|
Loading…
Reference in New Issue
Block a user