-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
GH-119169: Implement pathlib.Path.walk()
using os.walk()
#119573
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
Merged
Merged
Conversation
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
For silly reasons, pathlib's generic implementation of `walk()` currently resides in `glob._Globber`. This commit moves it into `pathlib._abc.PathBase.walk()` where it really belongs, and makes `pathlib.Path.walk()` call though to `os.walk()`. Symlink handling is a little different between the two `walk()` implementations when `followlinks=False`. In `pathlib` it means never following symlinks, not even for distinguishing between files and directories. In `os` it means never *walking* into symlinks, including any symlinks created by the user between iterations. We smooth over these differences with a private sentinel - `os._walk_symlinks_as_files` - that enables the pathlib behaviour.
I'm intensely embarrassed by my decision to add a |
Thanks @barneygale for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
May 29, 2024
…ythonGH-119573) For silly reasons, pathlib's generic implementation of `walk()` currently resides in `glob._Globber`. This commit moves it into `pathlib._abc.PathBase.walk()` where it really belongs, and makes `pathlib.Path.walk()` call `os.walk()`. (cherry picked from commit 7ff61f5) Co-authored-by: Barney Gale <[email protected]>
GH-119750 is a backport of this pull request to the 3.13 branch. |
barneygale
added a commit
that referenced
this pull request
May 29, 2024
…H-119573) (#119750) GH-119169: Implement `pathlib.Path.walk()` using `os.walk()` (GH-119573) For silly reasons, pathlib's generic implementation of `walk()` currently resides in `glob._Globber`. This commit moves it into `pathlib._abc.PathBase.walk()` where it really belongs, and makes `pathlib.Path.walk()` call `os.walk()`. (cherry picked from commit 7ff61f5) Co-authored-by: Barney Gale <[email protected]>
noahbkim
pushed a commit
to hudson-trading/cpython
that referenced
this pull request
Jul 11, 2024
…ython#119573) For silly reasons, pathlib's generic implementation of `walk()` currently resides in `glob._Globber`. This commit moves it into `pathlib._abc.PathBase.walk()` where it really belongs, and makes `pathlib.Path.walk()` call `os.walk()`.
estyxx
pushed a commit
to estyxx/cpython
that referenced
this pull request
Jul 17, 2024
…ython#119573) For silly reasons, pathlib's generic implementation of `walk()` currently resides in `glob._Globber`. This commit moves it into `pathlib._abc.PathBase.walk()` where it really belongs, and makes `pathlib.Path.walk()` call `os.walk()`.
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.
For silly reasons, pathlib's generic implementation of
walk()
currently resides inglob._Globber
. This commit moves it intopathlib._abc.PathBase.walk()
where it really belongs, and makespathlib.Path.walk()
call though toos.walk()
rather than using the generic impl.Symlink handling is a little different between the two
walk()
implementations whenfollowlinks=False
. Inpathlib
it means never following symlinks, not even for distinguishing between files and directories. Inos
it means never walking into symlinks, including any symlinks created by the user between iterations. We smooth over these differences with a private sentinel -os._walk_symlinks_as_files
- that enables the pathlib behaviour.No change of behaviour.
os.walk()
#119169