Open
Conversation
2698aad to
71c0273
Compare
The Bound<'_, PyCapsule>::pointer_checked does the same validation and is already used across the codebase
71c0273 to
38d5e6b
Compare
kevinjqliu
reviewed
Mar 13, 2026
Comment on lines
-50
to
-61
| if capsule_name.is_none() { | ||
| return Err(PyValueError::new_err(format!( | ||
| "Expected {name} PyCapsule to have name set." | ||
| ))); | ||
| } | ||
|
|
||
| let capsule_name = unsafe { capsule_name.unwrap().as_cstr().to_str()? }; | ||
| if capsule_name != name { | ||
| return Err(PyValueError::new_err(format!( | ||
| "Expected name '{name}' in PyCapsule, instead got '{capsule_name}'" | ||
| ))); | ||
| } |
Contributor
There was a problem hiding this comment.
We lose the error messages by removing this function. Would this be potentially confusing to end users?
Author
There was a problem hiding this comment.
Good point. The error messages from PyCapsule_GetPointer are ValueError("PyCapsule_GetPointer called with invalid PyCapsule object") and ValueError("PyCapsule_GetPointer called with incorrect name"). These error only happen if the "magic" methods return invalid capsules so they should only be encountered by people trying to implement them and not regular DataFusion users. Also, the stack trace should give a hint of which capsule is raising the error.
An option might be to wrap the error in a nicer message. WDYT?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
The
Bound<'_, PyCapsule>::pointer_checkedmethod does the same validation and is already used across the codebaseWhat changes are included in this PR?
validate_pycapsule.map_err(py_datafusion_err)?c_str!calls byc-literals (now supported by MSRV)Are there any user-facing changes?
Some error messages have changfed