Python pillow (better PIL) encoding error check

I just installed the Pillow package for my virtual user. Performing this action:

from PIL import Image, ImageFont, ImageDraw ImageFont.load_path('some_path') 

I get an error message:

 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/net/isilonP/public/rw/homes/cbl_adm/.virtualenvs/chembl_webservices/lib/python2.7/site-packages/PIL/ImageFont.py", line 264, in load_path if not isinstance(filename, "utf-8"): TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types 

And indeed, if you check out the official gihub repository ( https://github.com/python-imaging/Pillow/blob/master/PIL/ImageFont.py#L264 ), you can see this construct:

 if not isinstance(filename, "utf-8"): ... 

My question is: how to replace it with what really works?

+4
source share
1 answer

Someone missed the opportunity to test this method; correct spell:

 if not isinstance(filename, str): # ... 

because in the rest of the code it turns into str for Python 2 and Python 3.

I wrote out a transfer request after talking with an accompanying IRC.

Update: The patch is now merged.

+2
source

Source: https://habr.com/ru/post/1493481/


All Articles