GH-106747: Make pathlib ABC globbing more consistent with glob.glob() (#115056)

When expanding `**` wildcards, ensure we add a trailing slash to the
topmost directory path. This matches `glob.glob()` behaviour:

    >>> glob.glob('dirA/**', recursive=True)
    ['dirA/', 'dirA/dirB', 'dirA/dirB/dirC']

This does not affect `pathlib.Path.glob()`, because trailing slashes aren't
supported in pathlib proper.
This commit is contained in:
Barney Gale 2024-02-06 02:48:18 +00:00 committed by GitHub
parent 299e16ca0f
commit 1b1f8398d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 18 deletions

View file

@ -95,7 +95,7 @@ def _select_recursive(parent_paths, dir_only, follow_symlinks):
if follow_symlinks is None:
follow_symlinks = False
for parent_path in parent_paths:
paths = [parent_path]
paths = [parent_path._make_child_relpath('')]
while paths:
path = paths.pop()
yield path