File tree 2 files changed +9
-7
lines changed
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 {
41
41
match self {
42
42
Constant :: None => f. pad ( "None" ) ,
43
43
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) ,
48
47
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)
50
51
}
51
52
Constant :: Int ( i) => i. fmt ( f) ,
52
53
Constant :: Tuple ( tup) => {
Original file line number Diff line number Diff line change @@ -509,10 +509,11 @@ impl<'a> Unparser<'a> {
509
509
if is_spec {
510
510
self . unparse_fstring_body ( values, is_spec)
511
511
} else {
512
- use rustpython_common:: escape:: Escape ;
513
512
self . p ( "f" ) ?;
514
513
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 )
516
517
}
517
518
}
518
519
}
You can’t perform that action at this time.
0 commit comments