]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.9] Fix the test suite for the old parser (GH-27749)
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Fri, 13 Aug 2021 10:26:07 +0000 (11:26 +0100)
committerGitHub <noreply@github.com>
Fri, 13 Aug 2021 10:26:07 +0000 (12:26 +0200)
Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
Lib/test/test_exceptions.py
Lib/test/test_fstring.py
Lib/test/test_syntax.py

index 6dd3d5d9094228a8f91ca7b2f5d6b46fdba3b801..6f192d7d079eba7d6604a586cd57d9b1f752fac5 100644 (file)
@@ -235,7 +235,8 @@ class ExceptionTests(unittest.TestCase):
             """, 9, 20)
         check("pass\npass\npass\n(1+)\npass\npass\npass", 4, 4)
         check("(1+)", 1, 4)
-        check(b"\xef\xbb\xbf#coding: utf8\nprint('\xe6\x88\x91')\n", 0, -1)
+        check(b"\xef\xbb\xbf#coding: utf8\nprint('\xe6\x88\x91')\n", 0,
+              0 if support.use_old_parser() else -1)
 
         # Errors thrown by symtable.c
         check('x = [(yield i) for i in range(3)]', 1, 5)
index fbd97ffbdec80c1dd2ede97c08bf1722a46ac8a5..518ebdf16c1c694a1ee0a12beed9f625f3975174 100644 (file)
@@ -211,6 +211,7 @@ f'{a * f"-{x()}-"}'"""
         self.assertEqual(call.lineno, 3)
         self.assertEqual(call.col_offset, 11)
 
+    @unittest.skipIf(use_old_parser(), "The old parser gets the offsets incorrectly for fstrings")
     def test_ast_line_numbers_duplicate_expression(self):
         expr = """
 a = 10
@@ -277,6 +278,7 @@ f'{a * x()} {a * x()} {a * x()}'
         self.assertEqual(binop.left.col_offset, 23)
         self.assertEqual(binop.right.col_offset, 27)
 
+    @unittest.skipIf(use_old_parser(), "The old parser gets the offsets incorrectly for fstrings")
     def test_ast_numbers_fstring_with_formatting(self):
 
         t = ast.parse('f"Here is that pesky {xxx:.3f} again"')
index 74d97735e5fc453956e01f5426176be91f09c778..30d8e5a71800f2668ae487c4a0fdf33372326b1d 100644 (file)
@@ -429,9 +429,6 @@ SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
 >>> f((x)=2)
 Traceback (most recent call last):
 SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
->>> f(True=2)
-Traceback (most recent call last):
-SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
 >>> f(__debug__=1)
 Traceback (most recent call last):
 SyntaxError: cannot assign to __debug__
@@ -981,7 +978,7 @@ def func2():
     def test_invalid_line_continuation_error_position(self):
         self._check_error(r"a = 3 \ 4",
                           "unexpected character after line continuation character",
-                          lineno=1, offset=9)
+                          lineno=1, offset=(10 if support.use_old_parser() else 9))
 
     def test_invalid_line_continuation_left_recursive(self):
         # Check bpo-42218: SyntaxErrors following left-recursive rules