Skip to content

Commit 26f55c2

Browse files
authored
bpo-36817: Do not decrement reference for expr_text on fstring = parsing failure (pythonGH-13256)
1 parent 5833e94 commit 26f55c2

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Lib/test/test_fstring.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,8 @@ def __repr__(self):
11481148
self.assertEqual(f'{C()=:x}', 'C()=FORMAT-x')
11491149
self.assertEqual(f'{C()=!r:*^20}', 'C()=********REPR********')
11501150

1151+
self.assertRaises(SyntaxError, eval, "f'{C=]'")
1152+
11511153
def test_walrus(self):
11521154
x = 20
11531155
# This isn't an assignment expression, it's 'x', with a format

Python/ast.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5283,7 +5283,6 @@ fstring_find_expr(const char **str, const char *end, int raw, int recurse_lvl,
52835283
/* Falls through to error. */
52845284

52855285
error:
5286-
Py_XDECREF(expr_text);
52875286
return -1;
52885287

52895288
}

0 commit comments

Comments
 (0)