Skip to content

Raise CaptionReadTimingError for a non-numeric SAMI start time - #418

Open
eeshsaxena wants to merge 1 commit into
pbs:mainfrom
eeshsaxena:fix/sami-non-numeric-start
Open

Raise CaptionReadTimingError for a non-numeric SAMI start time#418
eeshsaxena wants to merge 1 commit into
pbs:mainfrom
eeshsaxena:fix/sami-non-numeric-start

Conversation

@eeshsaxena

Copy link
Copy Markdown

The SAMI reader raises a bare ValueError when a <SYNC> element's start attribute is not numeric:

SAMIReader().read("<SAMI><BODY><SYNC Start=abc><P>Hi</P></SYNC></BODY></SAMI>")
# ValueError: could not convert string to float: 'abc'

_translate_lang does int(float(start_str)). A missing start time already raises CaptionReadTimingError, so I wrapped the conversion to raise the same error ("Invalid start time ...") for an unparsable one. Valid SAMI is unchanged.

Added a test next to test_missing_start; it raises ValueError on main and passes with the change. Found it by fuzzing the readers with mutated captions.

The SAMI reader converted a SYNC element's start attribute with
int(float(start_str)), raising a bare ValueError when the value was not
numeric. A missing start already raises CaptionReadTimingError, so raise the
same error for an unparsable one.
@eeshsaxena
eeshsaxena requested a review from a team as a code owner August 15, 2026 02:12
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