mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
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:
parent
299e16ca0f
commit
1b1f8398d0
2 changed files with 18 additions and 18 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue