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

MAINT: remove undocumented __buffer__ attribute lookup #13049

Merged
merged 1 commit into from
Mar 4, 2019

Conversation

mattip
Copy link
Member

@mattip mattip commented Feb 26, 2019

If a python-level class defined the __buffer__ attribute, frombuffer(buf, ...) would assume it returns the instance as a buffer. This was undocumented and flaky: if the
__buffer__ attribute was a method it would not be called. I tried to search for where this was ever used and got back to the original numeric code, where once it was a method to be called, but elsewhere an attribute. This second use was preserved until today.

Since it is undocumented I do not think we need a deprecation cycle. Should this hit the mailing list?

@mhvk
Copy link
Contributor

mhvk commented Feb 27, 2019

It seems very reasonable to remove it; I guess a check on the mailing list is a good idea, just in case.

@charris
Copy link
Member

charris commented Mar 1, 2019

Should probably put something in the release notes too, maybe in Compatibility for reference and comment. Numarray isn't Numeric, both can be found on sourceforge and I don't see __buffer__ in Numeric, so it was something added by STScI. tp_as_buffer wasn't available in the very early Pythons, maybe that is why,

would return the instance as a buffer. This was undocumented and flaky: if the
``__buffer__`` attribute was a method it would not be called. This code was
removed. If needed, use ``frombuffer(memoryview(obj), ...)`` instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

@charris is this appropriate? Should it be in a different section?

Copy link
Member

Choose a reason for hiding this comment

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

I would put it in the Compatibility notes section and just say that it was non-functional and removed. We don't expect anyone to notice in practice, but if they do, there it is.

Copy link
Member Author

Choose a reason for hiding this comment

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

adopted

@charris charris merged commit c2fbbb1 into numpy:master Mar 4, 2019
@charris
Copy link
Member

charris commented Mar 4, 2019

In it goes. Thanks Matti.

@mattip mattip deleted the remove-buffer-check branch June 8, 2020 06:58
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.

None yet

3 participants