File tree 2 files changed +6
-2
lines changed
2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,10 @@ 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) => rustpython_common:: str:: repr ( s) . fmt ( f) ,
44
+ Constant :: Str ( s) => {
45
+ use rustpython_common:: escape:: Escape ;
46
+ rustpython_common:: escape:: UnicodeEscape :: new_repr ( s. as_str ( ) ) . write_quoted ( f)
47
+ }
45
48
Constant :: Bytes ( b) => {
46
49
f. pad ( & rustpython_common:: bytes:: repr ( b) . map_err ( |_err| std:: fmt:: Error ) ?)
47
50
}
Original file line number Diff line number Diff line change @@ -509,9 +509,10 @@ 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 ;
512
513
self . p ( "f" ) ?;
513
514
let body = to_string_fmt ( |f| Unparser :: new ( f) . unparse_fstring_body ( values, is_spec) ) ;
514
- fmt :: Display :: fmt ( & rustpython_common :: str :: repr ( & body) , & mut self . f )
515
+ rustpython_common :: escape :: UnicodeEscape :: new_repr ( & body) . write_quoted ( & mut self . f )
515
516
}
516
517
}
517
518
}
You can’t perform that action at this time.
0 commit comments