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

Allow PixelAccess to use Python __int__ when parsing x and y #5206

merged 2 commits into from Mar 31, 2021


Copy link

@radarhere radarhere commented Jan 14, 2021

Resolves #5048

The issue reports that

px = im.load()
px[numpy.int32(5), numpy.int32(5)]


TypeError: an integer is required

This PR calls __int__() on the object passed in, which should provide support for other kinds of objects as well.

Copy link

@Seikegn Seikegn commented Jan 14, 2021

Thank you for making life easier!

Copy link

@wiredfool wiredfool commented Jan 16, 2021

Do we need to do anything on PyAccess for this?

Copy link
Member Author

@radarhere radarhere commented Jan 18, 2021

Testing, I find that PyAccess works without this PR. The following code produces no error.

from PIL import Image
import numpy
im ="Tests/images/hopper.png")
pix = im.load()
print(pix.__class__)  # <class 'PIL.PyAccess._PyAccess32_3'>
pix[numpy.int32(1), numpy.int32(2)]

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

Successfully merging this pull request may close these issues.

4 participants