mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
GH-94694: Fix column offsets for multi-line method lookups (GH-94697)
This commit is contained in:
parent
a10cf2f6b3
commit
264b3ddfd5
4 changed files with 85 additions and 2 deletions
|
@ -702,6 +702,57 @@ class TracebackErrorLocationCaretTests(unittest.TestCase):
|
|||
)
|
||||
self.assertEqual(result_lines, expected_error.splitlines())
|
||||
|
||||
def test_multiline_method_call_a(self):
|
||||
def f():
|
||||
(None
|
||||
.method
|
||||
)()
|
||||
actual = self.get_exception(f)
|
||||
expected = [
|
||||
f"Traceback (most recent call last):",
|
||||
f" File \"{__file__}\", line {self.callable_line}, in get_exception",
|
||||
f" callable()",
|
||||
f" ^^^^^^^^^^",
|
||||
f" File \"{__file__}\", line {f.__code__.co_firstlineno + 2}, in f",
|
||||
f" .method",
|
||||
f" ^^^^^^",
|
||||
]
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_multiline_method_call_b(self):
|
||||
def f():
|
||||
(None.
|
||||
method
|
||||
)()
|
||||
actual = self.get_exception(f)
|
||||
expected = [
|
||||
f"Traceback (most recent call last):",
|
||||
f" File \"{__file__}\", line {self.callable_line}, in get_exception",
|
||||
f" callable()",
|
||||
f" ^^^^^^^^^^",
|
||||
f" File \"{__file__}\", line {f.__code__.co_firstlineno + 2}, in f",
|
||||
f" method",
|
||||
f" ^^^^^^",
|
||||
]
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
def test_multiline_method_call_c(self):
|
||||
def f():
|
||||
(None
|
||||
. method
|
||||
)()
|
||||
actual = self.get_exception(f)
|
||||
expected = [
|
||||
f"Traceback (most recent call last):",
|
||||
f" File \"{__file__}\", line {self.callable_line}, in get_exception",
|
||||
f" callable()",
|
||||
f" ^^^^^^^^^^",
|
||||
f" File \"{__file__}\", line {f.__code__.co_firstlineno + 2}, in f",
|
||||
f" . method",
|
||||
f" ^^^^^^",
|
||||
]
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
@cpython_only
|
||||
@requires_debug_ranges()
|
||||
class CPythonTracebackErrorCaretTests(TracebackErrorLocationCaretTests):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue