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

Function remove_importlib_frames_inner

crates/vm/src/import.rs:208–246  ·  view source on GitHub ↗
(
    vm: &VirtualMachine,
    tb: Option<PyRef<PyTraceback>>,
    always_trim: bool,
)

Source from the content-addressed store, hash-verified

206}
207
208fn remove_importlib_frames_inner(
209 vm: &VirtualMachine,
210 tb: Option<PyRef<PyTraceback>>,
211 always_trim: bool,
212) -> (Option<PyRef<PyTraceback>>, bool) {
213 let traceback = if let Some(tb) = tb {
214 tb
215 } else {
216 return (None, false);
217 };
218
219 let file_name = traceback.frame.code.source_path().as_str();
220
221 let (inner_tb, mut now_in_importlib) =
222 remove_importlib_frames_inner(vm, traceback.next.lock().clone(), always_trim);
223 if file_name == "_frozen_importlib" || file_name == "_frozen_importlib_external" {
224 if traceback.frame.code.obj_name.as_str() == "_call_with_frames_removed" {
225 now_in_importlib = true;
226 }
227 if always_trim || now_in_importlib {
228 return (inner_tb, now_in_importlib);
229 }
230 } else {
231 now_in_importlib = false;
232 }
233
234 (
235 Some(
236 PyTraceback::new(
237 inner_tb,
238 traceback.frame.clone(),
239 traceback.lasti,
240 traceback.lineno,
241 )
242 .into_ref(&vm.ctx),
243 ),
244 now_in_importlib,
245 )
246}
247
248// TODO: This function should do nothing on verbose mode.
249// TODO: Fix this function after making PyTraceback.next mutable

Callers 1

remove_importlib_framesFunction · 0.85

Calls 7

newFunction · 0.85
SomeClass · 0.50
as_strMethod · 0.45
source_pathMethod · 0.45
cloneMethod · 0.45
lockMethod · 0.45
into_refMethod · 0.45

Tested by

no test coverage detected