Skip to content

fix: return 0.0 multi_byte_usage for empty payloads - #774

Merged
Ousret merged 2 commits into
jawah:masterfrom
santhreal:fix/empty-raw-multi-byte-usage
Jul 19, 2026
Merged

Ousret merged 2 commits into
jawah:masterfrom
santhreal:fix/empty-raw-multi-byte-usage

Conversation

@santhreal

@santhreal santhreal commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

CharsetMatch.multi_byte_usage hits ZeroDivisionError when from_bytes(b'').best().multi_byte_usage. This PR fixes the regression with a focused test covering the case.

from_bytes(b'') yields a UTF-8 match whose raw length is 0; dividing by
len(raw) raised ZeroDivisionError. Treat empty as zero multi-byte usage.
@santhreal
santhreal requested a review from Ousret as a code owner July 18, 2026 23:14

@Ousret Ousret left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Ousret
Ousret merged commit 017c75c into jawah:master Jul 19, 2026
42 checks passed
@Ousret Ousret mentioned this pull request Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants