docs: warn packagers that a system uchardet detects non-UTF-8 less accurately - #67
Merged
wbarnha merged 1 commit intoAug 4, 2026
Conversation
…curately The system-uchardet section presented `enabled` as the recommended choice for distro packaging without noting that it produces a measurably worse build. The bundled copy compiles an encoding-only replacement for uchardet's multi-byte group prober; a system build links upstream's, so it loses both the throughput fix and the rejection of non-UTF-8 sequences that upstream reports as UTF-8. Over the in-tree non-UTF-8 corpus (1650 documents, 7 encodings, median of 3 runs) a system build reports 16.2% of documents as UTF-8 against 0.0% for the bundled build, at roughly half the throughput. That is the defect v3.0.0 was yanked for, so packagers should not discover it from a bug report. State the numbers, attribute the cause upstream rather than to the packaging option, and point packagers who cannot ship a bundled library at the overlay as a distro patch in the meantime.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #64 (same pattern as #65), so it targets that branch rather than
master.Why
#64's README section presents
enabledas the recommended choice for distro packaging. It does not mention that the resulting build detects non-UTF-8 input materially worse than the wheels do.The bundled copy compiles the encoding-only replacement for
nsMBCSGroupProberadded in #62. A system build links upstream's prober, so it loses both the throughput fix and the rejection of non-UTF-8 sequences that upstream reports as UTF-8.Measured over the in-tree corpus (
benchmarks/make_nonutf8_corpus.py, 1650 documents, 7 encodings, median of 3 runs; system library built from our pinned uchardet commit so the overlay is the only variable):uchardetThat 16.2% is the defect v3.0.0 was yanked from PyPI for. Packagers should not have to discover it from a downstream bug report. Full method in #64 (comment).
What changed
Docs only — no build or code changes.
enabledrow so it points at the caveat instead of reading as an unconditional recommendation.nsUTF8Probernever rejects invalid sequences on its own and its confidence never falls far enough for the candidate to be discarded. This is not something @mgorny's patch introduced.Caveat on the number
make_nonutf8_corpus.pybuilds documents from random mid-word slices and mixes languages within a document, which is adversarial for language-model detection — 16.2% is a corpus-specific rate, not a field rate. Reporting bytes as UTF-8 that do not decode as UTF-8 is a hard error either way, and the bundled build scores 0.0% on identical input.Related
A fix for the underlying upstream defect has been prepared (
nsUTF8ProberhandlingeError), which takes a system build to 0.0% mislabel. It is not merged upstream yet, and it exposes a separate Big5 false positive that needs its own fix, so the caveat stands for now. Once upstream carries both, the meson probe can move fromhas_function()to theversion:constraint the existing# TODOanticipates and this block can be deleted.Generated by Claude Code