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

Function syntax_error_set_msg

crates/vm/src/exceptions.rs:1086–1103  ·  view source on GitHub ↗
(
    exc: PyBaseExceptionRef,
    value: PySetterValue,
    vm: &VirtualMachine,
)

Source from the content-addressed store, hash-verified

1084}
1085
1086fn syntax_error_set_msg(
1087 exc: PyBaseExceptionRef,
1088 value: PySetterValue,
1089 vm: &VirtualMachine,
1090) -> PyResult<()> {
1091 let mut args = exc.args.write();
1092 let mut new_args = args.as_slice().to_vec();
1093 // Ensure the message slot at index 0 always exists for SyntaxError.args.
1094 if new_args.is_empty() {
1095 new_args.push(vm.ctx.none());
1096 }
1097 match value {
1098 PySetterValue::Assign(value) => new_args[0] = value,
1099 PySetterValue::Delete => new_args[0] = vm.ctx.none(),
1100 }
1101 *args = PyTuple::new_ref(new_args, &vm.ctx);
1102 Ok(())
1103}
1104
1105fn system_exit_code(exc: PyBaseExceptionRef) -> Option<PyObjectRef> {
1106 // SystemExit.code based on args length:

Callers

nothing calls this directly

Calls 6

to_vecMethod · 0.80
noneMethod · 0.80
writeMethod · 0.45
as_sliceMethod · 0.45
is_emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected