Improve SgiImagePlugin test coverage #8896
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Looking at SgiImagePlugin, I see that an error for the incorrect number of bands will never be raised.
Pillow/src/PIL/SgiImagePlugin.py
Lines 160 to 176 in 507fefb
Only L, RGB and RGBA modes are supported when saving.
Pillow/src/PIL/SgiImagePlugin.py
Lines 137 to 139 in 507fefb
In the first code snippet, you can see that
z = len(im.mode)would be setzto the correct values of 1 for L, 3 for RGB and 4 for RGBA. It is later set to 1 ifdimis 1 or 2, butdimonly has those values for L mode images, which should be 1 anyway.So the error can be removed.
After some code simplification, this adds coverage for the lines missing at https://app.codecov.io/gh/python-pillow/Pillow/blob/main/src%2FPIL%2FSgiImagePlugin.py