kevinjqliu commented on code in PR #1426:
URL:
https://github.com/apache/datafusion-python/pull/1426#discussion_r2932877373
##########
examples/datafusion-ffi-example/src/utils.rs:
##########
@@ -35,30 +34,10 @@ pub(crate) fn ffi_logical_codec_from_pycapsule(
};
let capsule = capsule.cast::<PyCapsule>()?;
- validate_pycapsule(capsule, "datafusion_logical_extension_codec")?;
-
let data: NonNull<FFI_LogicalExtensionCodec> = capsule
- .pointer_checked(Some(c_str!("datafusion_logical_extension_codec")))?
+ .pointer_checked(Some(c"datafusion_logical_extension_codec"))?
.cast();
let codec = unsafe { data.as_ref() };
Ok(codec.clone())
}
-
-pub(crate) fn validate_pycapsule(capsule: &Bound<PyCapsule>, name: &str) ->
PyResult<()> {
- let capsule_name = capsule.name()?;
- 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}'"
- )));
- }
Review Comment:
i think we lose the error messages by removing this function. Would this be
potentially confusing to end users?
##########
examples/datafusion-ffi-example/src/utils.rs:
##########
@@ -35,30 +34,10 @@ pub(crate) fn ffi_logical_codec_from_pycapsule(
};
let capsule = capsule.cast::<PyCapsule>()?;
- validate_pycapsule(capsule, "datafusion_logical_extension_codec")?;
-
let data: NonNull<FFI_LogicalExtensionCodec> = capsule
- .pointer_checked(Some(c_str!("datafusion_logical_extension_codec")))?
+ .pointer_checked(Some(c"datafusion_logical_extension_codec"))?
.cast();
let codec = unsafe { data.as_ref() };
Ok(codec.clone())
}
-
-pub(crate) fn validate_pycapsule(capsule: &Bound<PyCapsule>, name: &str) ->
PyResult<()> {
- let capsule_name = capsule.name()?;
- 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}'"
- )));
- }
Review Comment:
We lose the error messages by removing this function. Would this be
potentially confusing to end users?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]