diff --git a/crates/vm/src/exceptions.rs b/crates/vm/src/exceptions.rs index bbdb17a9b..09225d884 100644 --- a/crates/vm/src/exceptions.rs +++ b/crates/vm/src/exceptions.rs @@ -2214,16 +2214,16 @@ pub(super) mod types { } impl Representable for PyImportError { - fn repr_str(zelf: &Py, vm: &VirtualMachine) -> PyResult { + fn repr_wtf8(zelf: &Py, vm: &VirtualMachine) -> PyResult { let base: &Py = zelf .as_object() .downcast_ref() .expect("ImportError is a BaseException"); let mut has_args = !base.args().is_empty(); if zelf.name.load_owned().is_none() && zelf.path.load_owned().is_none() { - return PyBaseException::repr_str(base, vm); + return PyBaseException::repr_wtf8(base, vm); } - let mut result = PyBaseException::repr_str(base, vm)?; + let mut result = PyBaseException::repr_wtf8(base, vm)?; result.pop(); for (name, field) in [("name", &zelf.name), ("path", &zelf.path)] { if let Some(value) = field.load_owned() { @@ -2231,12 +2231,12 @@ pub(super) mod types { result.push_str(", "); } result.push_str(name); - result.push('='); - result.push_str(&value.repr(vm)?.to_string_lossy()); + result.push_char('='); + result.push_wtf8(value.repr(vm)?.as_wtf8()); has_args = true; } } - result.push(')'); + result.push_char(')'); Ok(result) } }