mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
[3.12] gh-126139: Improve error message location for future statement with unknown feature (GH-126140) (#126160)
(cherry picked from commit 224c370a36)
This commit is contained in:
parent
7812dc37ab
commit
e5c7543f12
4 changed files with 17 additions and 7 deletions
|
|
@ -316,8 +316,8 @@ class ExceptionTests(unittest.TestCase):
|
|||
check('def f():\n global x\n nonlocal x', 2, 3)
|
||||
|
||||
# Errors thrown by future.c
|
||||
check('from __future__ import doesnt_exist', 1, 1)
|
||||
check('from __future__ import braces', 1, 1)
|
||||
check('from __future__ import doesnt_exist', 1, 24)
|
||||
check('from __future__ import braces', 1, 24)
|
||||
check('x=1\nfrom __future__ import division', 2, 1)
|
||||
check('foo(1=2)', 1, 5)
|
||||
check('def f():\n x, y: int', 2, 3)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class FutureTest(unittest.TestCase):
|
|||
def test_badfuture3(self):
|
||||
with self.assertRaises(SyntaxError) as cm:
|
||||
from test.test_future_stmt import badsyntax_future3
|
||||
self.check_syntax_error(cm.exception, "badsyntax_future3", 3)
|
||||
self.check_syntax_error(cm.exception, "badsyntax_future3", 3, 24)
|
||||
|
||||
def test_badfuture4(self):
|
||||
with self.assertRaises(SyntaxError) as cm:
|
||||
|
|
@ -80,12 +80,12 @@ class FutureTest(unittest.TestCase):
|
|||
def test_badfuture8(self):
|
||||
with self.assertRaises(SyntaxError) as cm:
|
||||
from test.test_future_stmt import badsyntax_future8
|
||||
self.check_syntax_error(cm.exception, "badsyntax_future8", 3)
|
||||
self.check_syntax_error(cm.exception, "badsyntax_future8", 3, 24)
|
||||
|
||||
def test_badfuture9(self):
|
||||
with self.assertRaises(SyntaxError) as cm:
|
||||
from test.test_future_stmt import badsyntax_future9
|
||||
self.check_syntax_error(cm.exception, "badsyntax_future9", 3)
|
||||
self.check_syntax_error(cm.exception, "badsyntax_future9", 3, 39)
|
||||
|
||||
def test_badfuture10(self):
|
||||
with self.assertRaises(SyntaxError) as cm:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue