Remove escaped mac/windows eol from AST string value (#7724)

## Summary

This PR fixes the bug where the value of a string node type includes the
escaped mac/windows newline character.

Note that the token value still includes them, it's only removed when
parsing the string content.

## Test Plan

Add new test cases for the string node type to check that the escapes
aren't being included in the string value.

fixes: #7723
This commit is contained in:
Dhruv Manilawala 2023-10-01 07:37:59 +05:30 committed by GitHub
parent 488ec54d21
commit e72d617f4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 103 additions and 1 deletions

View file

@ -0,0 +1,23 @@
---
source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
Expr(
StmtExpr {
range: 0..18,
value: Constant(
ExprConstant {
range: 0..18,
value: Str(
StringConstant {
value: "text more text",
unicode: false,
implicit_concatenated: false,
},
),
},
),
},
),
]

View file

@ -0,0 +1,23 @@
---
source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
Expr(
StmtExpr {
range: 0..18,
value: Constant(
ExprConstant {
range: 0..18,
value: Str(
StringConstant {
value: "text more text",
unicode: false,
implicit_concatenated: false,
},
),
},
),
},
),
]

View file

@ -0,0 +1,23 @@
---
source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
Expr(
StmtExpr {
range: 0..19,
value: Constant(
ExprConstant {
range: 0..19,
value: Str(
StringConstant {
value: "text more text",
unicode: false,
implicit_concatenated: false,
},
),
},
),
},
),
]