Skip to content

🐛 fix(cache): hash filesystem path bytes - #230

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:bug/vpi28hmc-nonutf8-cache
Nov 3, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:bug/vpi28hmc-nonutf8-cache

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

DiskCache.py_info() encoded interpreter paths as strict UTF-8 before hashing them. A POSIX filename with an undecodable byte therefore raised UnicodeEncodeError and stopped discovery even when the interpreter worked without a disk cache. The cache now hashes the path's filesystem bytes. Fixes #198.

Filesystem path cache key

Python represents undecodable filename bytes with surrogateescape. Strict UTF-8 encoding rejected those surrogate characters. os.fsencode() reverses the filesystem conversion, so the cache key can be computed for the original path bytes.

Behavior changes

On POSIX, discovery can cache an interpreter whose path contains undecodable bytes. On Windows, the cache key continues to use UTF-8 path bytes.

Reported by Anthropic's OSS Scanner: ANT-2026-VPI28HMC.

@gaborbernat gaborbernat added the bug Something isn't working label Nov 3, 2026
@gaborbernat
gaborbernat merged commit 8548640 into tox-dev:main Nov 3, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-UTF-8 interpreter paths break DiskCache lookups

1 participant