Pillow
Pillow copied to clipboard
Assert fp is not None
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.