Skip to content

Stop superscript digits crashing the transcript reader - #58

Merged
devcodes9 merged 1 commit into
mainfrom
fix/superscript-digit-crash
Sep 26, 2026
Merged

devcodes9 merged 1 commit into
mainfrom
fix/superscript-digit-crash

Conversation

@devcodes9

Copy link
Copy Markdown
Owner

Problem

agsearch read crashed on a real session:

ValueError: invalid literal for int() with base 10: '¹'

_condense_line_numbers finds runs of bare line numbers with isdigit(), then calls int() on them. isdigit() accepts superscripts like ¹, but int() rejects them.

The same cleaner formats search result rows, so a match on such a message could crash a search too.

Fix

  • Use isdecimal() in both checks. It accepts exactly what int() parses.
  • Add a regression test in tests/test_transcript.py.
  • Add a CHANGELOG entry under Unreleased.

Test

  • python3 -m unittest discover tests: 182 tests pass.
  • agsearch read 29d080ce now renders the session that crashed.

`agsearch read` crashed with "invalid literal for int() with base 10: '¹'" on a
session that contained a footnote mark. `_condense_line_numbers` picks out runs
of bare line numbers with `isdigit()` and then calls `int()` on them, and the two
disagree: `isdigit()` accepts superscripts, `int()` rejects them.

`isdecimal()` accepts exactly what `int()` parses, so the check and the
conversion now agree. The same cleaner formats search result rows, so a match
on such a message could crash a search as well.
@devcodes9
devcodes9 merged commit dc7b1f8 into main Sep 26, 2026
6 checks passed
@devcodes9
devcodes9 deleted the fix/superscript-digit-crash branch September 26, 2026 12:06
medazizktata pushed a commit to medazizktata/ccfind that referenced this pull request Nov 17, 2026
`agsearch read` crashed with "invalid literal for int() with base 10: '¹'" on a
session that contained a footnote mark. `_condense_line_numbers` picks out runs
of bare line numbers with `isdigit()` and then calls `int()` on them, and the two
disagree: `isdigit()` accepts superscripts, `int()` rejects them.

`isdecimal()` accepts exactly what `int()` parses, so the check and the
conversion now agree. The same cleaner formats search result rows, so a match
on such a message could crash a search as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant