Skip to content

Commit 4bdc2d4

Browse files
Make common::repr throw error instead of panic (#4520)
1 parent 09b82e4 commit 4bdc2d4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎ast/src/constant.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::fmt::Error;
2+
13
use num_bigint::BigInt;
24
pub use rustpython_compiler_core::ConversionFlag;
35

@@ -42,7 +44,7 @@ impl std::fmt::Display for Constant {
4244
Constant::None => f.pad("None"),
4345
Constant::Bool(b) => f.pad(if *b { "True" } else { "False" }),
4446
Constant::Str(s) => rustpython_common::str::repr(s).fmt(f),
45-
Constant::Bytes(b) => f.pad(&rustpython_common::bytes::repr(b)),
47+
Constant::Bytes(b) => f.pad(&rustpython_common::bytes::repr(b).map_err(|_err| Error)?),
4648
Constant::Int(i) => i.fmt(f),
4749
Constant::Tuple(tup) => {
4850
if let [elt] = &**tup {

0 commit comments

Comments
 (0)