MCPcopy Index your code
hub / github.com/RustPython/RustPython / exception_group_projection

Function exception_group_projection

crates/vm/src/exceptions.rs:2939–2956  ·  view source on GitHub ↗

Project orig onto keep list, preserving nested structure. Returns an exception group containing only the exceptions from orig that are also in the keep list.

(
    orig: &PyObjectRef,
    keep: &[PyObjectRef],
    vm: &VirtualMachine,
)

Source from the content-addressed store, hash-verified

2937/// Returns an exception group containing only the exceptions from orig
2938/// that are also in the keep list.
2939fn exception_group_projection(
2940 orig: &PyObjectRef,
2941 keep: &[PyObjectRef],
2942 vm: &VirtualMachine,
2943) -> PyResult {
2944 if keep.is_empty() {
2945 return Ok(vm.ctx.none());
2946 }
2947
2948 // Collect all leaf IDs from keep list
2949 let mut leaf_ids = HashSet::new();
2950 for e in keep {
2951 collect_exception_group_leaf_ids(e, &mut leaf_ids, vm);
2952 }
2953
2954 // Split orig by matching leaf IDs, preserving structure
2955 split_by_leaf_ids(orig, &leaf_ids, vm)
2956}
2957
2958/// Recursively split an exception (group) by leaf IDs.
2959/// Returns the projection containing only matching leaves with preserved structure.

Callers 1

prep_reraise_starFunction · 0.85

Calls 5

newFunction · 0.85
split_by_leaf_idsFunction · 0.85
noneMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected