[arrow-pyarrow]: restore nicer pyarrow-arrow error message#9639
[arrow-pyarrow]: restore nicer pyarrow-arrow error message#9639alamb merged 2 commits intoapache:mainfrom
Conversation
Tpt
left a comment
There was a problem hiding this comment.
Thank you! Some minor improvement idea.
If you want I can prepare a new MR that build a similar nice error for each extraction of the crate while propagating the original error.
| ) -> PyResult<(Bound<'py, PyCapsule>, Bound<'py, PyCapsule>)> { | ||
| let tuple = value.call_method0("__arrow_c_array__")?; | ||
|
|
||
| if !tuple.is_instance_of::<PyTuple>() { |
There was a problem hiding this comment.
if I am not mistaken .extract() will fail if tuple is not a tuple, returning the exact same error. I think we can drop this case.
| )); | ||
| } | ||
|
|
||
| tuple.extract().map_err(|_| { |
There was a problem hiding this comment.
tip if you want to propagate the original error as a "cause" to get a sightly nicer backtrace:
| tuple.extract().map_err(|_| { | |
| tuple.extract().map_err(|e| { | |
| let err = PyTypeError::new_err( | |
| "Expected __arrow_c_array__ to return a tuple of (schema, array) capsules.", | |
| ); | |
| err.set_cause(value.py(), Some(e)); | |
| err |
That would be great -- thank you 🙏 |
|
Closing this one in favor of the work from @Tpt |
|
Actually, since this one is approved, I'll merge it in and then @Tpt can you prepare a follow on PR to improve the messages further? |
Which issue does this PR close?
Rationale for this change
@kylebarron says #9594 (comment):
What changes are included in this PR?
Restore the nice error
Are these changes tested?
yes, added a test
Are there any user-facing changes?