Pillow should require NumPy >= 1.23
What did you do?
I opened a truncated image file and converted it to an array to check the validity of the file. (The equivalent of this test, though my file was a tiff.)
What did you expect to happen?
OSError
What actually happened?
It returned an actual array. I didn't imshow it to see what was in the place of the missing bytes.
What are your OS, Python and Pillow versions?
- OS: ubuntu:20.04 from dockerhub
- Python: 3.8.10
- Pillow: 9.2.0
- Numpy: 1.19.5
I think it would be better to either (a) keep the workaround for old numpy versions or (b) require a numpy version that works in setup.py. The current setup is not self consistent.
Just for context, the reason you are specifying Pillow 9.2.0 is because of #6394.
Can I ask, what is it that lead you to update Pillow to the latest version, but not NumPy?
I'm not entirely sure which dependency caused it, but this was the result when I installed my package with pip. I assume one of my other dependencies defaulted to an older NumPy version, but I'm not sure which one. I'm still digging through to figure out a self consistent setup.
Regardless, in principle there doesn't have to be a particular reason - somebody could have an older NumPy installed already but no Pillow, and then run pip install pillow, and as it currently stands they would get Pillow 9.2.0 while keeping their old NumPy. They would then get bitten by this issue like I was.
NumPy is an optional dependency of Pillow. Performing a quick Google search, I don't think that an optional dependency can have a minimum version. Correct me if I missed something.
I then considered the possibility of raising an error if NumPy is too old in __array_interface__... but the problem in the first place (#5084) is that __array_interface__ can't raise anything except for a RecursionError or MemoryError.
So I don't think that b) is possible.
As for a), keeping the workaround, I'm not keen on introducing a change (#5379), reverting that change (#6394), and then re-introducing it... I think that's off-putting to users, who would prefer a consistent experience - whether or not an error is raised is not the only difference. See #6581.
What if we instead raised a warning when an error is triggered with older NumPy versions? I've created PR #6594 for this.
Ah, I see. That makes sense to me, thank you!