Repository navigation
bpo-38671: Make sure to return an absolute path in pathlib._WindowsFlavour.resolve() #17716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e503cd6
3f9d1b8
612b7f6
7cff82e
8f20c10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ | |
|
|
||
|
|
||
| if os.name == 'nt': | ||
| from nt import _getfinalpathname | ||
| from nt import _getfinalpathname, _getfullpathname | ||
| else: | ||
| _getfinalpathname = None | ||
|
|
||
|
|
@@ -194,7 +194,7 @@ def resolve(self, path, strict=False): | |
| return None # Means fallback on absolute | ||
| if strict: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines 189-191 make a bad assumption that the current working directory (CWD) is a final path. The CWD is an absolute path but not a final path. The assignment should be something like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
TIL. I like the |
||
| return self._ext_to_normal(_getfinalpathname(s)) | ||
| s = path = os.path.abspath(s) | ||
| s = path = _getfullpathname(s) | ||
| previous_s = None | ||
| tail_parts = [] # End of the path after the first one not found | ||
| while True: | ||
|
|
@@ -204,7 +204,8 @@ def resolve(self, path, strict=False): | |
| previous_s = s | ||
| s, tail = os.path.split(s) | ||
| tail_parts.append(tail) | ||
| if previous_s == s: # Root reached, fallback to abspath() | ||
| if previous_s == s: | ||
| # Root reached, fallback to _getfullpathname() | ||
| return path | ||
| else: | ||
| return os.path.join(s, *reversed(tail_parts)) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.