Skip to content

🐛 fix(deps): drop chardet for req file decoding#3820

Merged
gaborbernat merged 2 commits intotox-dev:mainfrom
gaborbernat:3818
Feb 24, 2026
Merged

🐛 fix(deps): drop chardet for req file decoding#3820
gaborbernat merged 2 commits intotox-dev:mainfrom
gaborbernat:3818

Conversation

@gaborbernat
Copy link
Copy Markdown
Member

@gaborbernat gaborbernat commented Feb 24, 2026

chardet v6 introduced critical performance regressions (chardet/chardet#321) that cause test pipelines to slow down by orders of magnitude — tests going from ~0.2s to ~70s each. Since tox 4.45.0 requires chardet>=6.0.0.post1, this forces all users onto the broken version. Fixes #3818.

The chardet library was only used in one place: detecting the encoding of requirements files via chardet.detect(). This is replaced with BOM detection and UTF-8 decoding with a locale-based fallback, matching pip's own _decode_req_file implementation. This handles UTF-8, UTF-16, and UTF-32 (with BOM) and falls back to the system locale encoding for non-UTF-8 files — the same strategy pip uses to read requirements files.

This removes chardet from the dependency tree entirely, eliminating the performance regression and reducing tox's install footprint.

@gaborbernat gaborbernat added the bug:minor does not affect many people or has no big impact label Feb 24, 2026
@gaborbernat gaborbernat changed the title 🐛 fix(cli): allow --help with invalid config files 🐛 fix(deps): drop chardet for req file decoding Feb 24, 2026
chardet v6 has critical performance regressions (chardet/chardet#321)
causing test pipelines to slow down by orders of magnitude.

Replace chardet with BOM detection and UTF-8 decoding with locale
fallback, matching pip's own `_decode_req_file` implementation.
@gaborbernat gaborbernat added the bug:normal affects many people or has quite an impact label Feb 24, 2026
@gaborbernat gaborbernat merged commit 579bdc9 into tox-dev:main Feb 24, 2026
28 checks passed
ssbarnea added a commit to ansible/molecule that referenced this pull request Feb 25, 2026
Avoids critical bug tox-dev/tox#3820 related to
newer chardet, older versions might still bring the buggy version and
this one no longer lists it as a dependency.

Fixes collection pipeline which was getting stuck due to this bug.
sergei-maertens added a commit to maykinmedia/django-common that referenced this pull request Mar 9, 2026
See tox-dev/tox#3820 - chardet 6
was indeed causing massive performance regressions. Tox
4.46+ does not rely on it any longer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided bug:minor does not affect many people or has no big impact bug:normal affects many people or has quite an impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tox 4.45.0 requires chardet v6 which is affected by critical performance issues

1 participant