Whole file

jawah/charset_normalizer

The author described this change as fix: return 0.0 multi_byte_usage for empty payloads (#774). It counts as a record because the check below fails on the code as it stood at 667b93c92 and passes on 017c75c26, with nothing else changed between the two runs.

Fix saved2026-07-19
Sharing licenceMIT · LICENSE
Change size+5 1

What the code was meant to do, written into the code itself as a save note

fix: return 0.0 multi_byte_usage for empty payloads (#774)

The change

7272
7373 @property
7474 def multi_byte_usage(self) -> float:
75- return 1.0 - (len(str(self)) / len(self.raw))
75+ # Empty payloads are valid (from_bytes(b"") returns a match); avoid /0.
76+ raw_len = len(self.raw)
77+ if raw_len == 0:
78+ return 0.0
79+ return 1.0 - (len(str(self)) / raw_len)
7680
7781 def __str__(self) -> str:
7882 # Lazy Str Loading

The check that tells the two apart

failpass·tests/test_base_detection.py::test_empty

Check file tests/test_base_detection.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 it667b93c9243cc650354562b871fcfcc35282fe97
Broken version dated2026-07-19
Modulecharset_normalizer.models
Units changedCharsetMatch
Fingerprinta4612e210d0ab546
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 jawah/charset_normalizer