(
any: &Bound<'_, PyAny>,
format_result: PyResult<Bound<'_, PyString>>,
f: &mut core::fmt::Formatter<'_>,
)
| 774 | } |
| 775 | |
| 776 | fn python_format( |
| 777 | any: &Bound<'_, PyAny>, |
| 778 | format_result: PyResult<Bound<'_, PyString>>, |
| 779 | f: &mut core::fmt::Formatter<'_>, |
| 780 | ) -> Result<(), core::fmt::Error> { |
| 781 | match format_result { |
| 782 | Result::Ok(s) => return f.write_str(&s.to_string_lossy()), |
| 783 | Result::Err(err) => err.write_unraisable(any.py(), Some(any)), |
| 784 | } |
| 785 | |
| 786 | match any.get_type().name() { |
| 787 | Result::Ok(name) => core::write!(f, "<unprintable {name} object>"), |
| 788 | Result::Err(_err) => f.write_str("<unprintable object>"), |
| 789 | } |
| 790 | } |
| 791 | |
| 792 | // The trait bound is needed to avoid running into the auto-deref recursion |
| 793 | // limit (error[E0055]), because `Bound<PyAny>` would deref into itself. See: |
no test coverage detected