8000 GH-93662: Make sure that column offsets are correct in multi-line method calls. by markshannon · Pull Request #93673 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-93662: Make sure that column offsets are correct in multi-line method calls. #93673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tidy up test
  • Loading branch information
markshannon committed Jun 13, 2022
commit f2429cd59faca2b40d4838413e243440b60699ed
14 changes: 4 additions & 10 deletions Lib/test/test_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,21 +574,15 @@ def positions_from_location_table(code):
for _ in range(length):
yield (line, end_line, col, end_col)

def lines_from_postions(positions):
last = None
res = []
for l, _, _, _ in positions:
if l != last:
res.append(l)
last = l
return res

def dedup(lst, prev=object()):
for item in lst:
if item != prev:
yield item
prev = item

def lines_from_postions(positions):
return dedup(l for (l, _, _, _) in positions)

def misshappen():
"""

Expand Down Expand Up @@ -646,7 +640,7 @@ def test_positions(self):
def check_lines(self, func):
co = func.__code__
lines1 = list(dedup(l for (_, _, l) in co.co_lines()))
lines2 = lines_from_postions(positions_from_location_table(co))
lines2 = list(lines_from_postions(positions_from_location_table(co)))
for l1, l2 in zip(lines1, lines2):
self.assertEqual(l1, l2)
self.assertEqual(len(lines1), len(lines2))
Expand Down
0