Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
e503cd63f9d1b8612b7f67cff82e8f20c10File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
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 | ||
| @@ -189,26 +189,26 @@ def compile_pattern(self, pattern): | ||
| def resolve(self, path, strict=False): | ||
| s = str(path) | ||
| if not s: | ||
| return path._accessor.getcwd() | ||
| s = path._accessor.getcwd() | ||
| if _getfinalpathname is None: | ||
| return None # Means fallback on absolute | ||
| if strict: | ||
| ||
| return self._ext_to_normal(_getfinalpathname(s)) | ||
| s = path = _getfullpathname(s) | ||
| previous_s = None | ||
| if _getfinalpathname is not None: | ||
| if strict: | ||
| return self._ext_to_normal(_getfinalpathname(s)) | ||
| tail_parts = [] # End of the path after the first one not found | ||
| while True: | ||
| try: | ||
| s = self._ext_to_normal(_getfinalpathname(s)) | ||
| except FileNotFoundError: | ||
| previous_s = s | ||
| s, tail = os.path.split(s) | ||
| tail_parts.append(tail) | ||
| if previous_s == s: | ||
| # Root reached, fallback to _getfullpathname() | ||
| return path | ||
| else: | ||
| tail_parts = [] # End of the path after the first one not found | ||
| while True: | ||
| try: | ||
| s = self._ext_to_normal(_getfinalpathname(s)) | ||
| except FileNotFoundError: | ||
| previous_s = s | ||
| s, tail = os.path.split(s) | ||
| tail_parts.append(tail) | ||
| if previous_s == s: | ||
| return path | ||
| else: | ||
| return os.path.join(s, *reversed(tail_parts)) | ||
| # Means fallback on absolute | ||
| return None | ||
| return os.path.join(s, *reversed(tail_parts)) | ||
| def _split_extended_path(self, s, ext_prefix=ext_namespace_prefix): | ||
| prefix = '' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| Ensure pathlib.Path.resolve(strict=False) returns an absolute path on | ||
| Windows when the path is relative and does not exist. |
Uh oh!
There was an error while loading. Please reload this page.