Skip to content

Commit

Permalink
Make common::repr throw error instead of panic (#4520)
Browse files Browse the repository at this point in the history
  • Loading branch information
minhrongcon2000 authored Feb 19, 2023
1 parent 09b82e4 commit 4bdc2d4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ast/src/constant.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Error;

use num_bigint::BigInt;
pub use rustpython_compiler_core::ConversionFlag;

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

0 comments on commit 4bdc2d4

Please sign in to comment.