Whole file
ilevkivskyi/com2ann
The author described this change as “Fix crash when type comment appears on continuation line (#17)”. It counts as a record because the checks below fail on the code as it stood at 9becb404c and pass on 18f47677f, with nothing else changed between the two runs.
Projectilevkivskyi/com2ann
Fix saved2019-06-11
Sharing licenceMIT · LICENSE
Change size+13 −1
What the code was meant to do, written into the code itself as a save note
Fix crash when type comment appears on continuation line (#17)
The change
| 374 | 374 | ||
| 375 | 375 | rv_end = comment.rvalue_end_line - 1 | |
| 376 | 376 | rv_start = comment.rvalue_start_line - 1 | |
| 377 | - | lines[rv_end] = strip_type_comment(lines[rv_end]) | |
| 377 | + | if re.search(TYPE_COM, lines[rv_end]): | |
| 378 | + | lines[rv_end] = strip_type_comment(lines[rv_end]) | |
| 379 | + | else: | |
| 380 | + | # Special case: type comment moved to a separate continuation line. | |
| 381 | + | assert (lines[rv_end].rstrip().endswith('\\') or | |
| 382 | + | lines[rv_end + 1].lstrip().startswith(')')) | |
| 383 | + | lines[rv_end + 1] = strip_type_comment(lines[rv_end + 1]) | |
| 384 | + | if not lines[rv_end + 1].strip(): | |
| 385 | + | del lines[rv_end + 1] | |
| 386 | + | # Also remove the \ symbol from the previous line. | |
| 387 | + | trailer = re.search(_TRAILER, lines[rv_end]) | |
| 388 | + | assert trailer | |
| 389 | + | lines[rv_end] = lines[rv_end].rstrip()[:-1].rstrip() + trailer.group() | |
| 378 | 390 | ||
| 379 | 391 | if comment.tuple_rvalue: | |
| 380 | 392 | # TODO: take care of (1, 2), (3, 4) with matching pars. |
The check that tells the two apart
fail→pass·src/test_com2ann.py::AssignTestCase::test_comment_on_separate_line
fail→pass·src/test_com2ann.py::AssignTestCase::test_continuation_using_parens
Check file src/test_com2ann.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it9becb404cbfef645ea249b62863ef95c44a45349
Broken version dated2019-06-11
Modulecom2ann
Units changedprocess_assign
Fingerprint6894e6bdc3b1023c
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in ilevkivskyi/com2ann
- 2025-06-02split_function_comment
- 2021-03-07process_assign
- 2019-06-12process_func_def
- 2019-06-12Fix keyword-only arguments (#23)
- 2019-06-12Fix signature wrapping when return type contains commas (#21)