-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## 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
- Loading branch information
1 parent
e72d617
commit e91ffe3
Showing
4 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
.../src/snapshots/ruff_python_parser__lexer__tests__fstring_single_quote_escape_mac_eol.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
), | ||
] |
25 changes: 25 additions & 0 deletions
25
...src/snapshots/ruff_python_parser__lexer__tests__fstring_single_quote_escape_unix_eol.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
), | ||
] |
25 changes: 25 additions & 0 deletions
25
.../snapshots/ruff_python_parser__lexer__tests__fstring_single_quote_escape_windows_eol.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
), | ||
] |