Whole file

jawah/charset_normalizer

The author described this change as fix: make CharsetMatch.__eq__ total for non-alias strings (#773). It counts as a record because the check below fails on the code as it stood at cc6840753 and passes on 667b93c92, 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: make CharsetMatch.__eq__ total for non-alias strings (#773)

The change

4040 def __eq__(self, other: object) -> bool:
4141 if not isinstance(other, CharsetMatch):
4242 if isinstance(other, str):
43- return iana_name(other) == self.encoding
43+ # Use non-strict iana_name so an operand that is not a known
44+ # encoding alias compares unequal instead of raising, keeping
45+ # __eq__ total as the data model requires (mirrors the lookup
46+ # in CharsetMatches.__getitem__).
47+ return iana_name(other, False) == self.encoding
4448 return False
4549 return self.encoding == other.encoding and self.fingerprint == other.fingerprint
4650

The check that tells the two apart

failpass·tests/test_base_detection.py::test_match_equality_with_arbitrary_string

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 itcc6840753f17f00dea4e339ce37507747217e916
Broken version dated2026-07-07
Modulecharset_normalizer.models
Units changedCharsetMatch
Fingerprintb1aface88f114874
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