Closed jonashaag closed 1 week ago
I've created #8308 to resolve this.
Interesting that I can reproduce it with Python 3.9, 3.11 and 3.12:
Python 3.9.13 (v3.9.13:6de2ca5339, May 17 2022, 11:37:23)
[Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image, ImageDraw
>>> img = Image.new("L", (1, 1))
>>> ImageDraw.Draw(img).text((0, 0), ("a", "b"))
[1] 25375 segmentation fault python3.9
But with the Python 3.13 release candidate, I get TypeError: expected bytes, tuple found
:
Python 3.13.0rc1 (v3.13.0rc1:e4a3e786a5e, Jul 31 2024, 19:49:53) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image, ImageDraw
... img = Image.new("L", (1, 1))
... ImageDraw.Draw(img).text((0, 0), ("a", "b"))
...
Traceback (most recent call last):
File "<python-input-0>", line 3, in <module>
ImageDraw.Draw(img).text((0, 0), ("a", "b"))
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/PIL/ImageDraw.py", line 696, in text
draw_text(ink)
~~~~~~~~~^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/PIL/ImageDraw.py", line 635, in draw_text
mask, offset = font.getmask2( # type: ignore[union-attr,misc]
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
text,
^^^^^
...<9 lines>...
**kwargs,
^^^^^^^^^
)
^
File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/PIL/ImageFont.py", line 607, in getmask2
return self.font.render(
~~~~~~~~~~~~~~~~^
text,
^^^^^
...<9 lines>...
start[1],
^^^^^^^^^
)
^
TypeError: expected bytes, tuple found
>>>
What did you do?
What did you expect to happen?
Should raise a
TypeError
What actually happened?
It crashed.
What are your OS, Python and Pillow versions?
pillow 10.4.0 py312h39b1d8d_0 40.4 MiB conda pillow-10.4.0-py312h39b1d8d_0.conda