(
category: PyTypeRef,
text: PyStrRef,
message: PyObjectRef,
filename: PyStrRef,
lineno: usize,
lineno_obj: PyObjectRef,
source_line: Option<PyObjectRef>,
source: Optio
| 454 | |
| 455 | #[allow(clippy::too_many_arguments)] |
| 456 | fn call_show_warning( |
| 457 | category: PyTypeRef, |
| 458 | text: PyStrRef, |
| 459 | message: PyObjectRef, |
| 460 | filename: PyStrRef, |
| 461 | lineno: usize, |
| 462 | lineno_obj: PyObjectRef, |
| 463 | source_line: Option<PyObjectRef>, |
| 464 | source: Option<PyObjectRef>, |
| 465 | vm: &VirtualMachine, |
| 466 | ) -> PyResult<()> { |
| 467 | let Some(show_fn) = |
| 468 | get_warnings_attr(vm, identifier!(&vm.ctx, _showwarnmsg), source.is_some())? |
| 469 | else { |
| 470 | return show_warning(filename, lineno, text, category, source_line, vm); |
| 471 | }; |
| 472 | if !show_fn.is_callable() { |
| 473 | return Err(vm.new_type_error("warnings._showwarnmsg() must be set to a callable")); |
| 474 | } |
| 475 | let Some(warnmsg_cls) = get_warnings_attr(vm, identifier!(&vm.ctx, WarningMessage), false)? |
| 476 | else { |
| 477 | return Err(vm.new_runtime_error("unable to get warnings.WarningMessage")); |
| 478 | }; |
| 479 | |
| 480 | let msg = warnmsg_cls.call( |
| 481 | vec![ |
| 482 | message, |
| 483 | category.into(), |
| 484 | filename.into(), |
| 485 | lineno_obj, |
| 486 | vm.ctx.none(), |
| 487 | vm.ctx.none(), |
| 488 | vm.unwrap_or_none(source), |
| 489 | ], |
| 490 | vm, |
| 491 | )?; |
| 492 | show_fn.call((msg,), vm)?; |
| 493 | Ok(()) |
| 494 | } |
| 495 | |
| 496 | fn show_warning( |
| 497 | filename: PyStrRef, |
no test coverage detected