GH-44626, GH-105476: Fix ntpath.isabs() handling of part-absolute paths#113829
Merged
Conversation
…t-absolute paths. On Windows, `os.path.isabs()` now returns `False` when given a path that starts with exactly one (back)slash. This is more compatible with other functions in `os.path`, and with Microsoft's own documentation. Also adjust `pathlib.PureWindowsPath.is_absolute()` to call `ntpath.isabs()`, which corrects its handling of partial UNC/device paths like `//foo`. Co-authored-by: Jon Foster <jon@jon-foster.co.uk>
zooba
approved these changes
Jan 8, 2024
Contributor
Author
|
Thank you for the review @zooba! |
kulikjak
pushed a commit
to kulikjak/cpython
that referenced
this pull request
Jan 22, 2024
…t-absolute paths (python#113829) On Windows, `os.path.isabs()` now returns `False` when given a path that starts with exactly one (back)slash. This is more compatible with other functions in `os.path`, and with Microsoft's own documentation. Also adjust `pathlib.PureWindowsPath.is_absolute()` to call `ntpath.isabs()`, which corrects its handling of partial UNC/device paths like `//foo`. Co-authored-by: Jon Foster <jon@jon-foster.co.uk>
aisk
pushed a commit
to aisk/cpython
that referenced
this pull request
Feb 11, 2024
…t-absolute paths (python#113829) On Windows, `os.path.isabs()` now returns `False` when given a path that starts with exactly one (back)slash. This is more compatible with other functions in `os.path`, and with Microsoft's own documentation. Also adjust `pathlib.PureWindowsPath.is_absolute()` to call `ntpath.isabs()`, which corrects its handling of partial UNC/device paths like `//foo`. Co-authored-by: Jon Foster <jon@jon-foster.co.uk>
Glyphack
pushed a commit
to Glyphack/cpython
that referenced
this pull request
Sep 2, 2024
…t-absolute paths (python#113829) On Windows, `os.path.isabs()` now returns `False` when given a path that starts with exactly one (back)slash. This is more compatible with other functions in `os.path`, and with Microsoft's own documentation. Also adjust `pathlib.PureWindowsPath.is_absolute()` to call `ntpath.isabs()`, which corrects its handling of partial UNC/device paths like `//foo`. Co-authored-by: Jon Foster <jon@jon-foster.co.uk>
jni
pushed a commit
to napari/napari
that referenced
this pull request
Jan 2, 2025
…path.isabs change (#7482) # References and relevant issues Needed by: #7481 # Description Python 3.13 changed how `os.path.isabs` works on Windows: python/cpython#113829 Specifically, it will now return False for paths like `/foo/bar` on Windows, while True on POSIX. For True on Windows the path now needs to be `\\foo\bar` We have 2 tests that use paths like `/foo/bar` and expect them to be considered absolute. In this PR, I add logic to test the proper paths on Windows using `\`. You can see all tests pass on 3.13 with this fix in my fork: https://github.com/psobolewskiPhD/napari/actions/runs/12574076907/job/35047736273 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
skshetry
added a commit
to treeverse/dvc
that referenced
this pull request
Jan 10, 2025
python/cpython#113829 changed `os.path.isabs` on Windows to not consider a path starting a single backslash to be an absolute path. We do a lot of naive `posixpath` to `ntpath` conversions, and it broke DVC in multiple places. DVC is likely broken in many other places, and these bugs are difficult to identify. In this commit, I have tried to fix in the places where the tests failed. And mostly by trying to imitate pre-3.13 behaviour. Some of the changes may not be correct but keeps the old behaviour in place. Also re-enabled the CI for all Python versions supported for Windows.
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.
On Windows,
os.path.isabs()now returnsFalsewhen given a path that starts with exactly one (back)slash. This is more compatible with other functions inos.path, and with Microsoft's own documentation.Also adjust
pathlib.PureWindowsPath.is_absolute()to callntpath.isabs(), which corrects its handling of partial UNC/device paths like//foo.📚 Documentation preview 📚: https://cpython-previews--113829.org.readthedocs.build/