[3.9] bpo-41084: Fix test_fstring failure when using the old parser (GH-21212)

diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
index 5c27b73..e0812d1 100644
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -524,7 +524,8 @@
                              # This looks like a nested format spec.
                              ])
 
-        self.assertAllRaise(SyntaxError, "f-string: invalid syntax",
+        err_msg = "invalid syntax" if use_old_parser() else "f-string: invalid syntax"
+        self.assertAllRaise(SyntaxError, err_msg,
                             [# Invalid syntax inside a nested spec.
                              "f'{4:{/5}}'",
                              ])
@@ -598,7 +599,8 @@
         #  are added around it. But we shouldn't go from an invalid
         #  expression to a valid one. The added parens are just
         #  supposed to allow whitespace (including newlines).
-        self.assertAllRaise(SyntaxError, 'f-string: invalid syntax',
+        err_msg = "invalid syntax" if use_old_parser() else "f-string: invalid syntax"
+        self.assertAllRaise(SyntaxError, err_msg,
                             ["f'{,}'",
                              "f'{,}'",  # this is (,), which is an error
                              ])
@@ -716,7 +718,8 @@
 
         # lambda doesn't work without parens, because the colon
         #  makes the parser think it's a format_spec
-        self.assertAllRaise(SyntaxError, 'f-string: invalid syntax',
+        err_msg = "invalid syntax" if use_old_parser() else "f-string: invalid syntax"
+        self.assertAllRaise(SyntaxError, err_msg,
                             ["f'{lambda x:x}'",
                              ])
 
@@ -1201,7 +1204,8 @@
         self.assertEqual(x, 10)
 
     def test_invalid_syntax_error_message(self):
-        with self.assertRaisesRegex(SyntaxError, "f-string: invalid syntax"):
+        err_msg = "invalid syntax" if use_old_parser() else "f-string: invalid syntax"
+        with self.assertRaisesRegex(SyntaxError, err_msg):
             compile("f'{a $ b}'", "?", "exec")