Repository navigation
🐛 fix: correct directory creation, lookup and test isolation - #745
Merged
gaborbernat merged 18 commits intoNov 20, 2026
Merged
Conversation
Record each scope's entry state so nested tests recover their own patches. Fork under the same lock used for context changes so workers inherit a complete redirect.
Allow group-writable parents for ordinary user paths. Keep stricter ownership and mode checks for runtime paths and privileged site writes. Cap new root site directories at 0755 under permissive umasks. Check each runtime search directory against its own base so a rejected override cannot hide a valid fallback. On macOS, use the checked user runtime directory for site lookup as well.
Use the checked user runtime path when creating beneath an XDG override. Root can still look up the invoking user's path. Accept an owned, group-writable temporary fallback for lookup and skip it in file searches until its owner repairs the permissions.
Android and container homes can have system-owned ancestors. Check each symlink and each entry in a writable parent. Keep runtime ownership checks strict and verify new directories before descending into them. Allow root to look up an existing service directory. Require root-owned components for creation or file placement. Cap new root site directories at 0755 and configured media directories at 0775 before applying the umask.
Use the same patch stack for the temporary runtime tree and its ownership overrides. Pytest can then remove old temporary directories with the original os.lstat after the tests finish.
Windows Python 3.11 drops the share when normalizing an extended UNC path ending in a parent reference at the share root. Later versions retain it. Check that the override is accepted only when the share survives.
The sticky bit still lets the directory owner rename entries. Require a shared sticky parent to belong to root or the caller before using it.
Use the same checked user runtime path for lookup and creation under an XDG override. Resolve it once when iterating. Root may look up an inherited runtime path, but creation requires a validated base.
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.
Applications can create private directories under Android's system-owned paths and in container homes owned by another account. Shared sticky directories, their entries and symlinks must belong to root or the caller. In a group-writable parent without the sticky bit, entries may also belong to the parent's owner. Group members can replace entries there after the check. Previous creation checks
Root can look up an existing service-owned Unix site directory. Creating a directory or calling a
place_*_filemethod there requires a root-owned path. Root-owned group-writable ancestors are allowed. Root requests mode0755for new site directories, subject to the umask. Unix also reads trusted media settings under a group-writable~/.configand requests mode0775for configured media directories.Unix site runtime lookup and creation select the same fallback for a rejected XDG override. With root redirection, a direct site lookup returns the inherited path. With
ensure_exists=True, it creates a missing base with mode0700and rejects an invalid base or parent. A rejected override no longer hides files in a valid fallback. A lookup can return a group-writable temporary fallback. File searches skip it untilensure_existsrepairs its mode. On macOS, searches find files placed in the native fallback. Windows ignores UNC folder overrides with a missing server or share, or with.or..as either name.All threads share the newest active
isolated_dirs()root. Forked children inherit it. Closing a nested context restores any patches that were in place when it opened. Overlapping contexts