pathlib ABCs: follow all symlinks in PathBase.glob() (#116293)

Switch the default value of *follow_symlinks* from `None` to `True` in
`pathlib._abc.PathBase.glob()` and `rglob()`. This speeds up recursive
globbing.

No change to the public pathlib classes.
This commit is contained in:
Barney Gale 2024-03-04 02:26:33 +00:00 committed by GitHub
parent 3383d6afa3
commit 1dce0073da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 40 deletions

View file

@ -789,7 +789,7 @@ class PathBase(PurePathBase):
def _make_child_relpath(self, name):
return self.joinpath(name)
def glob(self, pattern, *, case_sensitive=None, follow_symlinks=None):
def glob(self, pattern, *, case_sensitive=None, follow_symlinks=True):
"""Iterate over this subtree and yield all existing files (of any
kind, including directories) matching the given relative pattern.
"""
@ -846,7 +846,7 @@ class PathBase(PurePathBase):
paths = _select_children(paths, bool(stack), follow_symlinks, match)
return paths
def rglob(self, pattern, *, case_sensitive=None, follow_symlinks=None):
def rglob(self, pattern, *, case_sensitive=None, follow_symlinks=True):
"""Recursively yield all existing files (of any kind, including
directories) matching the given relative pattern, anywhere in
this subtree.