# HG changeset patch # User Emmanuel Gil Peyrot # Date 1467074455 -3600 # Node ID 20c1c9d7803d29a2abbd98342f6e1dc1c86140fc # Parent 6569eea3db23f692e3e0b0ee14be876d070aeb50 Fix dump failure in strings containing backquotes and double quotes. diff --git a/src/ast_dump.rs b/src/ast_dump.rs --- a/src/ast_dump.rs +++ b/src/ast_dump.rs @@ -195,7 +195,7 @@ impl ToStringable for expr { arguments.join(", ") }), expr::Num(n) => format!("{}", n), - expr::Str(s) => format!("\"{}\"", s), + expr::Str(s) => format!("\"{}\"", s.replace('\\', "\\\\").replace('"', "\\\"")), expr::Bytes(s) => format!("b\"{}\"", { let mut string = String::with_capacity(s.len()); for ascii_code in s { diff --git a/tests/test_parse_files/test_str.py b/tests/test_parse_files/test_str.py --- a/tests/test_parse_files/test_str.py +++ b/tests/test_parse_files/test_str.py @@ -1,1 +1,1 @@ -a = "test string" +a = "test \\ \"string\""