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

Added __int__ to IFDRational for Python >= 3.11 #6998

Merged
merged 1 commit into from
Mar 12, 2023

Conversation

radarhere
Copy link
Member

In Python 3.11, the following code

from PIL.TiffImagePlugin import IFDRational
ifd = IFDRational(1)
int(ifd)

gives

DeprecationWarning: The delegation of int() to __trunc__ is deprecated.
  int(ifd)

I noticed the deprecation warning in https://github.com/python-pillow/Pillow/actions/runs/4342791039/jobs/7584046826#step:8:4230

This deprecation was added in python/cpython#89140

This PR fixes the matter by adding __int__ to IFDRational - but only for Python >= 3.11. Below Python 3.11, this change gives

AttributeError: 'Fraction' object has no attribute '__int__'. Did you mean: '__init__'?

@hugovk hugovk merged commit 258cb8d into python-pillow:main Mar 12, 2023
@radarhere radarhere deleted the ifdrational branch March 12, 2023 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants