pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/3003fbbf00422bce6e327646063e97470afa9091

55097560d244c08.css" /> gh-113703: Correctly identify incomplete f-strings in the codeop modu… · python/cpython@3003fbb · GitHub
Skip to content

Commit 3003fbb

Browse files
authored
gh-113703: Correctly identify incomplete f-strings in the codeop module (#113709)
1 parent 0ae60b6 commit 3003fbb

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Lib/test/test_codeop.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ def test_incomplete(self):
223223
ai("(x for x in")
224224
ai("(x for x in (")
225225

226+
ai('a = f"""')
227+
ai('a = \\')
228+
226229
def test_invalid(self):
227230
ai = self.assertInvalid
228231
ai("a b")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a regression in the :mod:`codeop` module that was causing it to incorrectly
2+
identify incomplete f-strings. Patch by Pablo Galindo

Parser/lexer/lexer.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,9 +1355,13 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
13551355
tok->lineno = the_current_tok->f_string_line_start;
13561356

13571357
if (current_tok->f_string_quote_size == 3) {
1358-
return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok,
1358+
_PyTokenizer_syntaxerror(tok,
13591359
"unterminated triple-quoted f-string literal"
1360-
" (detected at line %d)", start));
1360+
" (detected at line %d)", start);
1361+
if (c != '\n') {
1362+
tok->done = E_EOFS;
1363+
}
1364+
return MAKE_TOKEN(ERRORTOKEN);
13611365
}
13621366
else {
13631367
return MAKE_TOKEN(_PyTokenizer_syntaxerror(tok,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy