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.
Projectjawah/charset_normalizer
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
| 40 | 40 | def __eq__(self, other: object) -> bool: | |
| 41 | 41 | if not isinstance(other, CharsetMatch): | |
| 42 | 42 | 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 | |
| 44 | 48 | return False | |
| 45 | 49 | return self.encoding == other.encoding and self.fingerprint == other.fingerprint | |
| 46 | 50 |
The check that tells the two apart
fail→pass·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
- 2026-07-19fix: return 0.0 multi_byte_usage for empty payloads (#774)
- 2026-07-07fix: unicodedecodeerror in fallback path
- 2025-08-09:bug: automatically fallback on valid UTF-16 or UTF-32 even if the md says it's noisy
- 2024-12-24:bug: output(...) replace declarative mark using non iana compliant encoding name