Skip to content

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