byroot / pysrt

Python parser for SubRip (srt) files
GNU General Public License v3.0
451 stars 69 forks source link

Handle division by zero in characters_per_second #48

Closed felagund closed 10 years ago

felagund commented 10 years ago

When duration is 0, the program used to throw an error. Now it returns 0. I am not sure if that is the best value to return (float('inf') could be used maybe) but cannot think of anything better and this seems better than throwing an exception.

byroot commented 10 years ago

Damn, I'm not doing enough Python lately, I though dividing by 0 in float context would return Inf like in most languages.

At first sight I'd tend to return inf, because that's logical.

But 0 second long subtitles, is a kind of convention for comments, or stale items. So players don't bother displaying them on any frame.

So 0.0 if definitely the value that make most sense.

THanks for that, but please add a test.

felagund commented 10 years ago

Test added.

byroot commented 10 years ago

LGTM. Thanks!