Skip to content

Reinstate __array__ on Python 3.10/3.11 #162

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

crusaderky
Copy link
Contributor

@crusaderky crusaderky commented Jul 11, 2025

Comment on lines +169 to +173
# We arrive here from np.asarray() on Python >=3.12 when __buffer__ raises.
raise RuntimeError(
f"Can't convert array on the '{self._device}' device to a "
"NumPy array."
)
Copy link
Contributor Author

@crusaderky crusaderky Jul 11, 2025

Choose a reason for hiding this comment

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

Previously, np.asarray() would raise ValueError: object __array__ method not producing an array because __buffer__ raised and __array__ subtly returned None. Changed to explicit behaviour.

@crusaderky crusaderky marked this pull request as ready for review July 11, 2025 11:30
@crusaderky
Copy link
Contributor Author

@ev-br @lucascolley ready for review

Copy link
Member

@lucascolley lucascolley left a comment

Choose a reason for hiding this comment

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

thanks Guido, LGTM!

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