Skip to content

Commit 560e957

Browse files
committed
Fix test_fstring
1 parent 6bfb095 commit 560e957

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Grammar/python.gram

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,8 +1462,10 @@ invalid_replacement_field:
14621462
TOK_GET_MODE(p->tok)->tstring ? 't' : 'f') }
14631463

14641464
invalid_conversion_character:
1465-
| '!' &(':' | '}') { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("%c-string: missing conversion character") }
1466-
| '!' !NAME { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("%c-string: invalid conversion character") }
1465+
| '!' &(':' | '}') { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("%c-string: missing conversion character",
1466+
TOK_GET_MODE(p->tok)->tstring ? 't' : 'f') }
1467+
| '!' !NAME { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("%c-string: invalid conversion character",
1468+
TOK_GET_MODE(p->tok)->tstring ? 't' : 'f') }
14671469

14681470
invalid_arithmetic:
14691471
| sum ('+'|'-'|'*'|'/'|'%'|'//'|'@') a='not' b=inversion { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "'not' after an operator must be parenthesized") }

Lib/test/test_fstring.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,6 @@ def test_conversions(self):
13461346
self.assertAllRaise(SyntaxError, "f-string: expecting '}'",
13471347
["f'{3!'",
13481348
"f'{3!s'",
1349-
"f'{3!g'",
13501349
])
13511350

13521351
self.assertAllRaise(SyntaxError, 'f-string: missing conversion character',

Parser/parser.c

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)