We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0a10e6c + 4c2ab63 commit 15fdf1eCopy full SHA for 15fdf1e
vm/src/bytesinner.rs
@@ -253,11 +253,12 @@ impl PyBytesInner {
253
}
254
255
pub fn repr_with_name(&self, class_name: &str, vm: &VirtualMachine) -> PyResult<String> {
256
+ const DECORATION_LEN: isize = 2 + 3; // 2 for (), 3 for b"" => bytearray(b"")
257
let escape = crate::literal::escape::AsciiEscape::new_repr(&self.elements);
258
let len = escape
259
.layout()
260
.len
- .and_then(|len| (len as isize).checked_add(2 + class_name.len() as isize))
261
+ .and_then(|len| (len as isize).checked_add(DECORATION_LEN + class_name.len() as isize))
262
.ok_or_else(|| Self::new_repr_overflow_error(vm))? as usize;
263
let mut buf = String::with_capacity(len);
264
buf.push_str(class_name);
0 commit comments