mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-19 01:50:38 +00:00
Consume the escaped Windows newline (\r\n
) for FStringMiddle
(#7722)
## Summary This PR fixes a bug where if a Windows newline (`\r\n`) character was escaped, then only the `\r` was consumed and not `\n` leading to an unterminated string error. ## Test Plan Add new test cases to check the newline escapes. fixes: #7632
This commit is contained in:
parent
e72d617f4b
commit
e91ffe3e93
4 changed files with 101 additions and 2 deletions
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/lexer.rs
|
||||
expression: fstring_single_quote_escape_eol(MAC_EOL)
|
||||
---
|
||||
[
|
||||
(
|
||||
FStringStart,
|
||||
0..2,
|
||||
),
|
||||
(
|
||||
FStringMiddle {
|
||||
value: "text \\\r more text",
|
||||
is_raw: false,
|
||||
},
|
||||
2..19,
|
||||
),
|
||||
(
|
||||
FStringEnd,
|
||||
19..20,
|
||||
),
|
||||
(
|
||||
Newline,
|
||||
20..20,
|
||||
),
|
||||
]
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/lexer.rs
|
||||
expression: fstring_single_quote_escape_eol(UNIX_EOL)
|
||||
---
|
||||
[
|
||||
(
|
||||
FStringStart,
|
||||
0..2,
|
||||
),
|
||||
(
|
||||
FStringMiddle {
|
||||
value: "text \\\n more text",
|
||||
is_raw: false,
|
||||
},
|
||||
2..19,
|
||||
),
|
||||
(
|
||||
FStringEnd,
|
||||
19..20,
|
||||
),
|
||||
(
|
||||
Newline,
|
||||
20..20,
|
||||
),
|
||||
]
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
source: crates/ruff_python_parser/src/lexer.rs
|
||||
expression: fstring_single_quote_escape_eol(WINDOWS_EOL)
|
||||
---
|
||||
[
|
||||
(
|
||||
FStringStart,
|
||||
0..2,
|
||||
),
|
||||
(
|
||||
FStringMiddle {
|
||||
value: "text \\\r\n more text",
|
||||
is_raw: false,
|
||||
},
|
||||
2..20,
|
||||
),
|
||||
(
|
||||
FStringEnd,
|
||||
20..21,
|
||||
),
|
||||
(
|
||||
Newline,
|
||||
21..21,
|
||||
),
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue