Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated categories #5351

Merged
merged 2 commits into from Mar 28, 2021
Merged

Deprecated categories #5351

merged 2 commits into from Mar 28, 2021

Conversation

@radarhere
Copy link
Member

@radarhere radarhere commented Mar 22, 2021

Images have a category property. It is set to Image.NORMAL

self.category = NORMAL

Unless the image format is MIC and there are multiple frames, in which case it is Image.CONTAINER.

if len(self.images) > 1:
self.category = Image.CONTAINER

There is also the unused attribute Image.SEQUENCE.

Pillow/src/PIL/Image.py

Lines 190 to 193 in aa35f6b

# categories
NORMAL = 0
SEQUENCE = 1
CONTAINER = 2

This minimal support across formats shows the feature has clearly not kept up with our other changes around multi-frame images, and can be deprecated in favour of is_animated.

@hugovk
Copy link
Member

@hugovk hugovk commented Mar 27, 2021

I'm fine with deprecating it.

It was a pain when we initally removed Image.PILLOW_VERSION without active deprecation warnings (only warnings in docs).

I expect calls to im.category are less common, but shall we nevertheless include deprecation warnings?

@radarhere
Copy link
Member Author

@radarhere radarhere commented Mar 28, 2021

Ok, sure. I've added deprecation warnings.

However, not for Python 3.6, since __getattr__ was only added in Python 3.7 - but Python 3.6 reaches EOL at the end of this year, so even if a user switched across to Python 3.7 at the start of 2022, they would still have a full year of seeing the warnings before the feature was removed.

@hugovk
Copy link
Member

@hugovk hugovk commented Mar 28, 2021

Sounds good, thank you!

@hugovk hugovk merged commit e405ab3 into python-pillow:master Mar 28, 2021
49 of 50 checks passed
@radarhere radarhere deleted the categories branch Mar 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants