Skip to content

Commit c465662

Browse files
authored
Merge pull request RustPython#2169 from hyperbora/fix-bytes-repr
Troubleshooting displaying bytes in the wrong hexadecimal number in certain cases.
2 parents cc25db9 + aa378b9 commit c465662

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

vm/src/bytesinner.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,11 @@ impl PyBytesInner {
252252
let mut res = String::with_capacity(self.elements.len());
253253
for i in self.elements.iter() {
254254
match i {
255-
0..=8 => res.push_str(&format!("\\x0{}", i)),
256255
9 => res.push_str("\\t"),
257256
10 => res.push_str("\\n"),
258-
11 => res.push_str(&format!("\\x0{:x}", i)),
259257
13 => res.push_str("\\r"),
260258
32..=126 => res.push(*(i) as char),
261-
_ => res.push_str(&format!("\\x{:x}", i)),
259+
_ => res.push_str(&format!("\\x{:02x}", i)),
262260
}
263261
}
264262
res

0 commit comments

Comments
 (0)