Skip to content

Commit fa7f12b

Browse files
committed
Fix test_tokenize
1 parent 76974c3 commit fa7f12b

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

Include/internal/pycore_token.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ extern "C" {
9191
(x) == INDENT || \
9292
(x) == DEDENT)
9393
#define ISSTRINGLIT(x) ((x) == STRING || \
94-
(x) == FSTRING_MIDDLE || \
95-
(x) == FSTRING_END)
94+
(x) == FSTRING_MIDDLE)
9695

9796

9897
// Symbols exported for test_peg_generator

Lib/test/test_tokenize.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,8 @@ def test_string(self):
19381938

19391939
self.check_tokenize('f"abc"', """\
19401940
FSTRING_START 'f"' (1, 0) (1, 2)
1941-
FSTRING_END 'abc' (1, 2) (1, 5)
1941+
FSTRING_MIDDLE 'abc' (1, 2) (1, 5)
1942+
FSTRING_END '"' (1, 5) (1, 6)
19421943
""")
19431944

19441945
self.check_tokenize('fR"a{b}c"', """\
@@ -1947,24 +1948,28 @@ def test_string(self):
19471948
LBRACE '{' (1, 4) (1, 5)
19481949
NAME 'b' (1, 5) (1, 6)
19491950
RBRACE '}' (1, 6) (1, 7)
1950-
FSTRING_END 'c' (1, 7) (1, 8)
1951+
FSTRING_MIDDLE 'c' (1, 7) (1, 8)
1952+
FSTRING_END '"' (1, 8) (1, 9)
19511953
""")
19521954

19531955
self.check_tokenize('f"""abc"""', """\
19541956
FSTRING_START 'f\"""' (1, 0) (1, 4)
1955-
FSTRING_END 'abc' (1, 4) (1, 7)
1957+
FSTRING_MIDDLE 'abc' (1, 4) (1, 7)
1958+
FSTRING_END '\"""' (1, 7) (1, 10)
19561959
""")
19571960

19581961
self.check_tokenize(r'f"abc\
19591962
def"', """\
19601963
FSTRING_START \'f"\' (1, 0) (1, 2)
1961-
FSTRING_END 'abc\\\\\\ndef' (1, 2) (2, 3)
1964+
FSTRING_MIDDLE 'abc\\\\\\ndef' (1, 2) (2, 3)
1965+
FSTRING_END '"' (2, 3) (2, 4)
19621966
""")
19631967

19641968
self.check_tokenize(r'Rf"abc\
19651969
def"', """\
19661970
FSTRING_START 'Rf"' (1, 0) (1, 3)
1967-
FSTRING_END 'abc\\\\\\ndef' (1, 3) (2, 3)
1971+
FSTRING_MIDDLE 'abc\\\\\\ndef' (1, 3) (2, 3)
1972+
FSTRING_END '"' (2, 3) (2, 4)
19681973
""")
19691974

19701975
def test_function(self):

0 commit comments

Comments
 (0)