Skip to content

fix: report dtype/ndim error when extracting PyReadonlyArray/PyReadwriteArray#562

Open
flying-sheep wants to merge 1 commit into
PyO3:mainfrom
flying-sheep:fix-extract-msg
Open

fix: report dtype/ndim error when extracting PyReadonlyArray/PyReadwriteArray#562
flying-sheep wants to merge 1 commit into
PyO3:mainfrom
flying-sheep:fix-extract-msg

Conversation

@flying-sheep

@flying-sheep flying-sheep commented Jul 21, 2026

Copy link
Copy Markdown

Fixes #561

Doesn’t address extracting Bound<PyArray> because that’s truly impossible with pyo3’s current API.

@Icxolu Icxolu left a comment

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.

You're right, we can do that for PyReadonlyArray and PyReadwriteArray as these are our types and we can control the FromPyObject implementation. It means that there is now a mismatch in error message between PyReadonlyArray/PyReadwriteArray and Bound<PyArray>, but given the advantage it's probably justified. (It also makes me less sad about the change to PyErr as this makes #560 basically free)

Comment thread src/borrow/mod.rs Outdated
Comment thread CHANGELOG.md Outdated
@flying-sheep

Copy link
Copy Markdown
Author

If you want a more semantic error, we could create a new error enum wrapping CastError, (D)TypeError, DimensionalityError, or BorrowError. I think that covers all of them.

If you want I can also just roll #560 into this one.

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.

Bound<PyArray>>, PyReadonlyArray and PyReadwriteArray all create useless extract messages on dtype/shape mismatch

2 participants