Skip to content

Commit b72e268

Browse files
committed
Keep bytes conversion diagnostics WTF-8 compatible
Use the shared lossless concatenation helper so the qualified-name migration composes without restoring Rust Display formatting. Assisted-by: OpenAI Codex:model version not exposed
1 parent 24a4a64 commit b72e268

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎crates/vm/src/builtins/bytes.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use crate::{
3030
use bstr::ByteSlice;
3131
use core::{mem::size_of, ops::Deref};
3232
use memchr::memchr;
33+
use rustpython_common::wtf8::wtf8_concat;
3334

3435
#[pyclass(module = false, name = "bytes")]
3536
#[derive(Clone, Debug)]
@@ -134,8 +135,10 @@ impl Constructor for PyBytes {
134135
obj.class().fully_qualified_name(vm),
135136
result.class().fully_qualified_name(vm),
136137
) {
137-
(Ok(source), Ok(result)) => vm.new_type_error(format!(
138-
"{source}.__bytes__() must return a bytes, not {result}"
138+
(Ok(source), Ok(result)) => vm.new_type_error(wtf8_concat!(
139+
source,
140+
".__bytes__() must return a bytes, not ",
141+
result
139142
)),
140143
(Err(error), _) | (_, Err(error)) => error,
141144
}

0 commit comments

Comments
 (0)