Skip to content

Commit

Permalink
Fixed a bug that led to a false positive error when using a single-qu…
Browse files Browse the repository at this point in the history
…ote form of a format string that uses a format specifier expression. This is also a bug in the Python 3.12 interpreter that is being fixed. This addresses #6077. (#6082)

Co-authored-by: Eric Traut <[email protected]>
  • Loading branch information
erictraut and msfterictraut authored Oct 4, 2023
1 parent b7bbbd6 commit 808a348
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/parser/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ export class Tokenizer<KeywordT extends number> {
}
}
} else if (this._cs.currentChar === Char.LineFeed || this._cs.currentChar === Char.CarriageReturn) {
if (!isTriplicate) {
if (!isTriplicate && !isFString) {
// Unterminated single-line string
flags |= StringTokenFlags.Unterminated;
return { escapedValue: String.fromCharCode.apply(undefined, escapedValueParts), flags };
Expand Down
6 changes: 6 additions & 0 deletions packages/pyright-internal/src/tests/samples/fstring1.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,9 @@ def func1(x):

v2 = f'x \
y'

w1 = 1

w2 = f"__{
w1:d
}__"

0 comments on commit 808a348

Please sign in to comment.