From b4b8249c9d7678dc8c08efa4c32a2b4b17a26b54 Mon Sep 17 00:00:00 2001 From: nulano Date: Sat, 16 Apr 2022 17:46:43 +0200 Subject: [PATCH] None is also not a valid value --- Tests/test_imagefont.py | 3 +++ src/PIL/ImageFont.py | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index a8fdddc24..c074c5205 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -981,6 +981,9 @@ class TestImageFont: font = self.get_font() with pytest.warns(DeprecationWarning): font.getmask2("Hello world", fill=Image.core.fill) + with pytest.raises(TypeError): + with pytest.warns(DeprecationWarning): + font.getmask2("Hello world", fill=None) @skip_unless_feature("raqm") diff --git a/src/PIL/ImageFont.py b/src/PIL/ImageFont.py index 77dce3bc6..7a34160f9 100644 --- a/src/PIL/ImageFont.py +++ b/src/PIL/ImageFont.py @@ -64,6 +64,9 @@ except ImportError: core = _imagingft_not_installed() +_UNSPECIFIED = object() + + # FIXME: add support for pilfont2 format (see FontFile.py) # -------------------------------------------------------------------- @@ -602,7 +605,7 @@ class FreeTypeFont: self, text, mode="", - fill=None, + fill=_UNSPECIFIED, direction=None, features=None, language=None, @@ -676,7 +679,7 @@ class FreeTypeFont: :py:mod:`PIL.Image.core` interface module, and the text offset, the gap between the starting coordinate and the first marking """ - if fill is not None: + if fill is not _UNSPECIFIED: deprecate("fill", 10) else: fill = Image.core.fill