Skip to content

Commit d163647

Browse files
committed
Add lineno to exceptions
Thanks to Ruff for reminding me
1 parent 8b8a2f9 commit d163647

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

Doc/tools/version_next.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,14 @@ def main(argv):
6363
lines = []
6464
with open(path, encoding='utf-8') as file:
6565
for lineno, line in enumerate(file, start=1):
66-
if match := DIRECTIVE_RE.fullmatch(line):
67-
line = match['before'] + version + match['after']
68-
num_changed_lines += 1
69-
lines.append(line)
66+
try:
67+
if match := DIRECTIVE_RE.fullmatch(line):
68+
line = match['before'] + version + match['after']
69+
num_changed_lines += 1
70+
lines.append(line)
71+
except Exception as exc:
72+
exc.add_note(f'processing line {path}:{lineno}')
73+
raise
7074
if num_changed_lines:
7175
if args.verbose:
7276
print(f'Updating file {path} ({num_changed_lines} changes)',

0 commit comments

Comments
 (0)