File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 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 {
4141 match self {
4242 Constant :: None => f. pad ( "None" ) ,
4343 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+ }
4548 Constant :: Bytes ( b) => {
4649 f. pad ( & rustpython_common:: bytes:: repr ( b) . map_err ( |_err| std:: fmt:: Error ) ?)
4750 }
Original file line number Diff line number Diff line change @@ -509,9 +509,10 @@ impl<'a> Unparser<'a> {
509509 if is_spec {
510510 self . unparse_fstring_body ( values, is_spec)
511511 } else {
512+ use rustpython_common:: escape:: Escape ;
512513 self . p ( "f" ) ?;
513514 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 )
515516 }
516517 }
517518}
You can’t perform that action at this time.
0 commit comments