aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/pathlib/_abc.py
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2024-02-06 02:48:18 +0000
committerGitHub <noreply@github.com>2024-02-06 02:48:18 +0000
commit1b1f8398d0ffe3c8ba2cca79d0c0f19a6a34e72a (patch)
treebb1cf363b3e007a040e2a1f55108bdd709bda4e9 /Lib/pathlib/_abc.py
parent299e16ca0f303a1e00bd0e04679862a5d4db5ab2 (diff)
downloadcpython-1b1f8398d0ffe3c8ba2cca79d0c0f19a6a34e72a.tar.gz
cpython-1b1f8398d0ffe3c8ba2cca79d0c0f19a6a34e72a.zip
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.
Diffstat (limited to 'Lib/pathlib/_abc.py')
-rw-r--r--Lib/pathlib/_abc.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/pathlib/_abc.py b/Lib/pathlib/_abc.py
index 91f5cd6c01e..e4b1201a370 100644
--- a/Lib/pathlib/_abc.py
+++ b/Lib/pathlib/_abc.py
@@ -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