File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,13 @@ impl std::fmt::Display for Constant {
4141 match self {
4242 Constant :: None => f. pad ( "None" ) ,
4343 Constant :: Bool ( b) => f. pad ( if * b { "True" } else { "False" } ) ,
44- Constant :: Str ( s) => {
45- use rustpython_common:: escape:: Escape ;
46- rustpython_common:: escape:: UnicodeEscape :: new_repr ( s. as_str ( ) ) . write_quoted ( f)
47- }
44+ Constant :: Str ( s) => rustpython_common:: escape:: UnicodeEscape :: new_repr ( s. as_str ( ) )
45+ . str_repr ( )
46+ . write ( f) ,
4847 Constant :: Bytes ( b) => {
49- f. pad ( & rustpython_common:: bytes:: repr ( b) . map_err ( |_err| std:: fmt:: Error ) ?)
48+ let escape = rustpython_common:: escape:: AsciiEscape :: new_repr ( b) ;
49+ let repr = escape. bytes_repr ( ) . to_string ( ) . unwrap ( ) ;
50+ f. pad ( & repr)
5051 }
5152 Constant :: Int ( i) => i. fmt ( f) ,
5253 Constant :: Tuple ( tup) => {
Original file line number Diff line number Diff line change @@ -509,10 +509,11 @@ impl<'a> Unparser<'a> {
509509 if is_spec {
510510 self . unparse_fstring_body ( values, is_spec)
511511 } else {
512- use rustpython_common:: escape:: Escape ;
513512 self . p ( "f" ) ?;
514513 let body = to_string_fmt ( |f| Unparser :: new ( f) . unparse_fstring_body ( values, is_spec) ) ;
515- rustpython_common:: escape:: UnicodeEscape :: new_repr ( & body) . write_quoted ( & mut self . f )
514+ rustpython_common:: escape:: UnicodeEscape :: new_repr ( & body)
515+ . str_repr ( )
516+ . write ( & mut self . f )
516517 }
517518 }
518519}
You can’t perform that action at this time.
0 commit comments