Skip to content

Commit 7928beb

Browse files
authored
Merge pull request #8124 from radarhere/imagedraw_getdraw
2 parents ecf3a98 + 4679e4b commit 7928beb

File tree

4 files changed

+25
-16
lines changed

4 files changed

+25
-16
lines changed

Tests/test_imagedraw.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,3 +1624,8 @@ def test_incorrectly_ordered_coordinates(xy: tuple[int, int, int, int]) -> None:
16241624
draw.rectangle(xy)
16251625
with pytest.raises(ValueError):
16261626
draw.rounded_rectangle(xy)
1627+
1628+
1629+
def test_getdraw():
1630+
with pytest.warns(DeprecationWarning):
1631+
ImageDraw.getdraw(None, [])

docs/deprecations.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ Support for LibTIFF earlier than 4
115115
Support for LibTIFF earlier than version 4 has been deprecated.
116116
Upgrade to a newer version of LibTIFF instead.
117117

118+
ImageDraw.getdraw hints parameter
119+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
120+
121+
.. deprecated:: 10.4.0
122+
123+
The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been deprecated.
124+
118125
Removed features
119126
----------------
120127

docs/releasenotes/10.4.0.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ Support for LibTIFF earlier than 4
3434
Support for LibTIFF earlier than version 4 has been deprecated.
3535
Upgrade to a newer version of LibTIFF instead.
3636

37+
ImageDraw.getdraw hints parameter
38+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
39+
40+
The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been deprecated.
41+
3742
API Changes
3843
===========
3944

src/PIL/ImageDraw.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
from typing import TYPE_CHECKING, AnyStr, Sequence, cast
3838

3939
from . import Image, ImageColor
40+
from ._deprecate import deprecate
4041
from ._typing import Coords
4142

4243
"""
@@ -904,26 +905,17 @@ def Draw(im, mode: str | None = None) -> ImageDraw:
904905

905906
def getdraw(im=None, hints=None):
906907
"""
907-
(Experimental) A more advanced 2D drawing interface for PIL images,
908-
based on the WCK interface.
909-
910908
:param im: The image to draw in.
911-
:param hints: An optional list of hints.
909+
:param hints: An optional list of hints. Deprecated.
912910
:returns: A (drawing context, drawing resource factory) tuple.
913911
"""
914-
# FIXME: this needs more work!
915-
# FIXME: come up with a better 'hints' scheme.
916-
handler = None
917-
if not hints or "nicest" in hints:
918-
try:
919-
from . import _imagingagg as handler
920-
except ImportError:
921-
pass
922-
if handler is None:
923-
from . import ImageDraw2 as handler
912+
if hints is not None:
913+
deprecate("'hints' parameter", 12)
914+
from . import ImageDraw2
915+
924916
if im:
925-
im = handler.Draw(im)
926-
return im, handler
917+
im = ImageDraw2.Draw(im)
918+
return im, ImageDraw2
927919

928920

929921
def floodfill(

0 commit comments

Comments
 (0)