From 26f55c29f2316648939ad12a9d3730a2118da2ea Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Sun, 12 May 2019 01:43:04 +0100 Subject: [PATCH] bpo-36817: Do not decrement reference for expr_text on fstring = parsing failure (GH-13256) --- Lib/test/test_fstring.py | 2 ++ Python/ast.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py index a0fae50d17..3484fcecf1 100644 --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -1148,6 +1148,8 @@ non-important content self.assertEqual(f'{C()=:x}', 'C()=FORMAT-x') self.assertEqual(f'{C()=!r:*^20}', 'C()=********REPR********') + self.assertRaises(SyntaxError, eval, "f'{C=]'") + def test_walrus(self): x = 20 # This isn't an assignment expression, it's 'x', with a format diff --git a/Python/ast.c b/Python/ast.c index 585f8b3fba..03da4e7f7f 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -5283,7 +5283,6 @@ unexpected_end_of_string: /* Falls through to error. */ error: - Py_XDECREF(expr_text); return -1; } -- 2.40.0