Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ffd3413

Browse filesBrowse files
committed
Add additional tests for column locations
1 parent dd5a391 commit ffd3413
Copy full SHA for ffd3413

File tree

Expand file treeCollapse file tree

2 files changed

+52
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+52
-1
lines changed

‎Lib/test/test_traceback.py

Copy file name to clipboardExpand all lines: Lib/test/test_traceback.py
+51Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,57 @@ class A: pass
702702
)
703703
self.assertEqual(result_lines, expected_error.splitlines())
704704

705+
def test_multiline_method_call_a(self):
706+
def f():
707+
(None
708+
.method
709+
)()
710+
actual = self.get_exception(f)
711+
expected = [
712+
f"Traceback (most recent call last):",
713+
f" File \"{__file__}\", line {self.callable_line}, in get_exception",
714+
f" callable()",
715+
f" ^^^^^^^^^^",
716+
f" File \"{__file__}\", line {f.__code__.co_firstlineno + 2}, in f",
717+
f" .method",
718+
f" ^^^^^^",
719+
]
720+
self.assertEqual(actual, expected)
721+
722+
def test_multiline_method_call_b(self):
723+
def f():
724+
(None.
725+
method
726+
)()
727+
actual = self.get_exception(f)
728+
expected = [
729+
f"Traceback (most recent call last):",
730+
f" File \"{__file__}\", line {self.callable_line}, in get_exception",
731+
f" callable()",
732+
f" ^^^^^^^^^^",
733+
f" File \"{__file__}\", line {f.__code__.co_firstlineno + 2}, in f",
734+
f" method",
735+
f" ^^^^^^",
736+
]
737+
self.assertEqual(actual, expected)
738+
739+
def test_multiline_method_call_c(self):
740+
def f():
741+
(None
742+
. method
743+
)()
744+
actual = self.get_exception(f)
745+
expected = [
746+
f"Traceback (most recent call last):",
747+
f" File \"{__file__}\", line {self.callable_line}, in get_exception",
748+
f" callable()",
749+
f" ^^^^^^^^^^",
750+
f" File \"{__file__}\", line {f.__code__.co_firstlineno + 2}, in f",
751+
f" . method",
752+
f" ^^^^^^",
753+
]
754+
self.assertEqual(actual, expected)
755+
705756
@cpython_only
706757
@requires_debug_ranges()
707758
class CPythonTracebackErrorCaretTests(TracebackErrorLocationCaretTests):

‎Python/compile.c

Copy file name to clipboardExpand all lines: Python/compile.c
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4738,7 +4738,7 @@ update_location_to_match_attr(struct compiler *c, expr_ty meth)
47384738
// Make start location match attribute
47394739
c->u->u_loc.lineno = meth->end_lineno;
47404740
int len = (int)PyUnicode_GET_LENGTH(meth->v.Attribute.attr);
4741-
// The dot may or not be on this line. Don't try to include it in the
4741+
// We have no idea where the dot is. Don't try to include it in the
47424742
// column span, it's more trouble than it's worth:
47434743
if (len <= meth->end_col_offset) {
47444744
// |---- end_col_offset

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.