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

Function raise_syntax_error

crates/stdlib/src/_tokenize.rs:458–472  ·  view source on GitHub ↗

Raise a SyntaxError with the given message and position.

(
        vm: &VirtualMachine,
        msg: &str,
        lineno: usize,
        offset: usize,
    )

Source from the content-addressed store, hash-verified

456
457 /// Raise a SyntaxError with the given message and position.
458 fn raise_syntax_error(
459 vm: &VirtualMachine,
460 msg: &str,
461 lineno: usize,
462 offset: usize,
463 ) -> rustpython_vm::builtins::PyBaseExceptionRef {
464 let exc = vm.new_exception_msg(vm.ctx.exceptions.syntax_error.to_owned(), msg.into());
465 let obj = exc.as_object();
466 let _ = obj.set_attr("msg", vm.ctx.new_str(msg), vm);
467 let _ = obj.set_attr("lineno", vm.ctx.new_int(lineno), vm);
468 let _ = obj.set_attr("offset", vm.ctx.new_int(offset), vm);
469 let _ = obj.set_attr("filename", vm.ctx.new_str("<string>"), vm);
470 let _ = obj.set_attr("text", vm.ctx.none(), vm);
471 exc
472 }
473
474 /// Raise an IndentationError from a parse error.
475 fn raise_indentation_error(

Callers 1

emit_next_tokenFunction · 0.85

Calls 7

new_exception_msgMethod · 0.80
noneMethod · 0.80
to_ownedMethod · 0.45
as_objectMethod · 0.45
set_attrMethod · 0.45
new_strMethod · 0.45
new_intMethod · 0.45

Tested by

no test coverage detected