Repository navigation
🐛 fix(py-info): reject sysconfig format widths - #229
Merged
gaborbernat merged 1 commit intoNov 3, 2026
Merged
Conversation
An interpreter can report a path pattern with a field width large enough to exhaust the caller when it requests an installation path. Reject format specifiers before expanding the pattern.
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.
PythonInfo.sysconfig_path() expanded an interpreter-reported path pattern with
str.format(). A reported field width made oneinstall_path("purelib")call allocate a 2 GB string in the caller, as issue #199 reproduces. The method now rejects format specifiers before expanding the pattern. Fixes #199.An interpreter-controlled width reached
str.format()The Python format specification syntax permits field widths after a colon. The interpreter collector records unexpanded sysconfig path patterns, and the old
sysconfig_path()passed those patterns tostr.format(). The new check usesFormatter.parse()to reject nonempty format specifications before formatting.Behavior changes
When a candidate reports a format specifier in a sysconfig path,
sysconfig_path()andinstall_path()raiseValueErrornaming the key. Patterns with ordinary placeholders keep their existing path results on POSIX and Windows.Reported by Anthropic's OSS Scanner: ANT-2026-XID4AAXX.