Skip to content

Avoid mutating caller-owned path segments during load and add - #204

Open
rupayon123 wants to merge 1 commit into
gruns:masterfrom
rupayon123:contribution/path-segment-ownership-20260920
Open

rupayon123 wants to merge 1 commit into
gruns:masterfrom
rupayon123:contribution/path-segment-ownership-20260920

Conversation

@rupayon123

Copy link
Copy Markdown

Copy caller-owned path segments before loading or adding them. Previously, Path(['', 'a']) removed the caller's leading segment, constructing from another Path shared its mutable segment list, and Path('/').add(source_path) could change the source from /a into //a. The destination now owns its segment container.

Four regression tests fail before the fix and pass afterward. The full Python3.11.15 nose2 run contains81 tests with the same one failure and two errors as unchanged master's77-test run (test_odd_urls, test_hosts, test_netloc). Flake8 passes for the changed source and tests; diff whitespace checks pass.

This addresses aliasing only; the separate absoluteness issue in #202 is not duplicated. Tests do not claim that constructing from an absolute Path already preserves its absoluteness.

AI-assisted with OpenAI Codex for rupayon123. Found by source inspection and reproduced with both caller lists and Path objects. No production-usage claim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant