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

Method unwind_stack_for_lineno

crates/vm/src/frame.rs:1401–1417  ·  view source on GitHub ↗

Perform deferred stack unwinding after set_f_lineno. set_f_lineno cannot pop the value stack directly because the execution loop holds the state mutex. Instead it records the work in `pending_stack_pops` / `pending_unwind_from_stack` and we execute it here, inside the execution loop where we already own the state.

(&mut self, pop_count: usize, from_stack: i64, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1399 /// `pending_stack_pops` / `pending_unwind_from_stack` and we execute it
1400 /// here, inside the execution loop where we already own the state.
1401 fn unwind_stack_for_lineno(&mut self, pop_count: usize, from_stack: i64, vm: &VirtualMachine) {
1402 let mut cur_stack = from_stack;
1403 for _ in 0..pop_count {
1404 let val = self.pop_value_opt();
1405 if stack_analysis::top_of_stack(cur_stack) == stack_analysis::Kind::Except as i64
1406 && let Some(exc_obj) = val
1407 {
1408 if vm.is_none(&exc_obj) {
1409 vm.set_exception(None);
1410 } else {
1411 let exc = exc_obj.downcast::<PyBaseException>().ok();
1412 vm.set_exception(exc);
1413 }
1414 }
1415 cur_stack = stack_analysis::pop_value(cur_stack);
1416 }
1417 }
1418
1419 /// Fire 'exception' trace event (sys.settrace) with (type, value, traceback) tuple.
1420 /// Matches `_PyEval_MonitorRaise` → `PY_MONITORING_EVENT_RAISE` →

Callers 1

runMethod · 0.80

Calls 6

top_of_stackFunction · 0.85
pop_valueFunction · 0.85
pop_value_optMethod · 0.80
okMethod · 0.80
is_noneMethod · 0.45
set_exceptionMethod · 0.45

Tested by

no test coverage detected