Skip to content

MAINT: __array_interface__ data address cannot be bytes#17241

Merged
charris merged 2 commits into
numpy:masterfrom
charris:cleanup-pyarray_frominterface
Sep 7, 2020
Merged

MAINT: __array_interface__ data address cannot be bytes#17241
charris merged 2 commits into
numpy:masterfrom
charris:cleanup-pyarray_frominterface

Conversation

@charris
Copy link
Copy Markdown
Member

@charris charris commented Sep 3, 2020

The old version 1 __array_interface__ implementation allowed the
data pointer value to be passed as a string, in version 2 an integer was
required, but the old code accepting a string remained. Remove that bit
of code from PyArray_FromInterface.

The old version 1 ``__array_interface__`` implementation allowed the
data pointer value to be passed as a string, in version 2 an integer was
required, but the old code accepting a string remained. Remove that bit
of code from PyArray_FromInterface.
Copy link
Copy Markdown
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch looks fine, I'm ok with this if we think we can get away with skipping a deprecation warning.

@eric-wieser eric-wieser changed the title MAINT: __array_interface__ data address cannot be string. MAINT: __array_interface__ data address cannot be bytes Sep 3, 2020
@charris
Copy link
Copy Markdown
Member Author

charris commented Sep 3, 2020

@eric-wieser It's a bit of a gamble, but I think it is pretty safe. Folks making the transition to Python 3 would probably have noticed if they were using strings. I need to add a release note though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The ``__array_interface__`` data tuple first element must be an integer
The first element of the ``__array_interface__["data"]`` tuple must be an integer

@charris charris force-pushed the cleanup-pyarray_frominterface branch from 31d7e6f to 14f2a1d Compare September 3, 2020 23:15
@charris
Copy link
Copy Markdown
Member Author

charris commented Sep 4, 2020

Updated.

@seberg
Copy link
Copy Markdown
Member

seberg commented Sep 4, 2020

I am OK with giving this a shot. Will probably merge this tomorrow, unless anyone has reason to be more cautious? Getting the correct string seems so tricky, that I am unsure where it would arise, besides maybe debugging where you copy paste a pointer representation?!

The main danger would be some library actually relying on it creating issues for a small group of third party users.

@seberg seberg self-requested a review September 4, 2020 01:59
@charris charris merged commit 34ab10d into numpy:master Sep 7, 2020
@charris charris deleted the cleanup-pyarray_frominterface branch December 19, 2020 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants