[Python-checkins] bpo-36817: Do not decrement reference for expr_text on fstring = parsing failure (GH-13256)

Pablo Galindo webhook-mailer at python.org
Sat May 11 20:43:08 EDT 2019


https://github.com/python/cpython/commit/26f55c29f2316648939ad12a9d3730a2118da2ea
commit: 26f55c29f2316648939ad12a9d3730a2118da2ea
branch: master
author: Pablo Galindo <Pablogsal at gmail.com>
committer: GitHub <noreply at github.com>
date: 2019-05-12T01:43:04+01:00
summary:

bpo-36817: Do not decrement reference for expr_text on fstring = parsing failure (GH-13256)

files:
M Lib/test/test_fstring.py
M Python/ast.c

diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
index a0fae50d1720..3484fcecf1c5 100644
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -1148,6 +1148,8 @@ def __repr__(self):
         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 585f8b3fba4c..03da4e7f7f9a 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -5283,7 +5283,6 @@ fstring_find_expr(const char **str, const char *end, int raw, int recurse_lvl,
     /* Falls through to error. */
 
 error:
-    Py_XDECREF(expr_text);
     return -1;
 
 }



More information about the Python-checkins mailing list