bpo-33660: Fix corner-case in PosixPath.resolve resulting in "//path"#21971
Closed
mbarkhau wants to merge 1 commit into
Closed
bpo-33660: Fix corner-case in PosixPath.resolve resulting in "//path"#21971mbarkhau wants to merge 1 commit into
"//path"#21971mbarkhau wants to merge 1 commit into
Conversation
On posix, when `Path.cwd() == "/"`, the `Path("var").resolve()`
produced `"//var"`. This is because the sep usually needs to be
added together with a prefix/base to a relative path, as the
prefix/base does not usually end with the sep itself. In this
respect, the root directory is a corner-case that was previously
missed.
Contributor
Author
|
I see now this relates to https://bugs.python.org/issue33660 |
"//path""//path"
Contributor
Author
|
Related: psf/black#1631 |
Contributor
|
Thanks for this but I'd rather merge the original PR by Dong-Hee Na. |
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.
This PR is provisional, a bpo doesn't exist yet.
On POSIX, when
Path.cwd() == Path("/"), thenPath("path").resolve() == Path("//var")This is because the normal case is that
sepmust be added between the base path and the relative path, as the prefix/base does not usually end withsepitself. In this respect, the root directoryPath("/")is a corner-case that I believe was previously missed.A consequence of this can be that the
relative_tomethod raises an error, even though the intent was to just normalize different both absolute and relative paths to relative paths:https://bugs.python.org/issue33660