fix(py): a panic in the library raises clawhdf5.InternalError, not PanicException
PanicException derives from BaseException, so `except Exception` let a library bug through. Every call from the bindings into the library now runs under catch_unwind and a panic becomes InternalError (RuntimeError) naming the object. Tests: a hidden hook panics inside the guard; and the v4 chunk indexes are compared with h5py from Python — with the library fix reverted, ds[0:30] of the implicit-index dataset now raises InternalError instead of aborting the test run. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -73,16 +73,18 @@ pub(crate) fn get_item(
|
||||
|
||||
/// Names of the group's datasets and subgroups, sorted (h5py's order).
|
||||
pub(crate) fn member_names(file: &clawhdf5_rs::File, path: &str) -> PyResult<Vec<String>> {
|
||||
let group = if path.is_empty() {
|
||||
file.root()
|
||||
} else {
|
||||
file.group(path).map_err(to_py_err)?
|
||||
};
|
||||
let mut names = group.datasets().map_err(to_py_err)?;
|
||||
names.extend(group.groups().map_err(to_py_err)?);
|
||||
names.sort_by(|a, b| a.as_bytes().cmp(b.as_bytes()));
|
||||
names.dedup();
|
||||
Ok(names)
|
||||
crate::no_panic(|| {
|
||||
let group = if path.is_empty() {
|
||||
file.root()
|
||||
} else {
|
||||
file.group(path).map_err(to_py_err)?
|
||||
};
|
||||
let mut names = group.datasets().map_err(to_py_err)?;
|
||||
names.extend(group.groups().map_err(to_py_err)?);
|
||||
names.sort_by(|a, b| a.as_bytes().cmp(b.as_bytes()));
|
||||
names.dedup();
|
||||
Ok(names)
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn contains(file: &clawhdf5_rs::File, path: &str, key: &str) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user