Skip to content

Commit 2fe8993

Browse files
dan-blanchardclaude
andcommitted
fix: handle missing ISO_TO_LANGUAGE in older chardet versions
The benchmark scripts run in venvs with different chardet versions installed. ISO_TO_LANGUAGE was added recently and doesn't exist in 7.1.0 or earlier, causing ImportError when benchmarking old versions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2831276 commit 2fe8993

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

scripts/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
import tempfile
1010
from pathlib import Path
1111

12-
from chardet._utils import ISO_TO_LANGUAGE
12+
try:
13+
from chardet._utils import ISO_TO_LANGUAGE
14+
except ImportError:
15+
# Older chardet versions don't have ISO_TO_LANGUAGE in _utils.
16+
# Provide an empty dict so scripts still work (language normalization
17+
# will fall back to passthrough for old versions).
18+
ISO_TO_LANGUAGE: dict[str, str] = {} # type: ignore[no-redef]
1319

1420
_TEST_DATA_REPO = "https://github.com/chardet/test-data.git"
1521
_REF_FILE = ".test-data-ref"

0 commit comments

Comments
 (0)