Raise a SyntaxError with the given message and position.
(
vm: &VirtualMachine,
msg: &str,
lineno: usize,
offset: usize,
)
| 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( |
no test coverage detected