Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

Assert fp is not None

Open radarhere opened this issue 1 year ago • 0 comments

This is part of #8362 - I'm hoping to break down that PR into easier-to-review chunks.

ImageFile's fp may be None.

>>> from PIL import Image
>>> im = Image.open("Tests/images/hopper.png")
>>> im.fp
<_io.BufferedReader name='Tests/images/hopper.png'>
>>> im.close()
>>> im.fp is None
True

So before using it, let's assert that it isn't None.

radarhere avatar Dec 23 '24 00:12 radarhere