mirror of
https://github.com/python/cpython.git
synced 2025-09-06 17:02:26 +00:00
GH-70303: Make pathlib.Path.glob('**')
return both files and directories (#114684)
Return files and directories from `pathlib.Path.glob()` if the pattern ends with `**`. This is more compatible with `PurePath.full_match()` and with other glob implementations such as bash and `glob.glob()`. Users can add a trailing slash to match only directories. In my previous patch I added a `FutureWarning` with the intention of fixing this in Python 3.15. Upon further reflection I think this was an unnecessarily cautious remedy to a clear bug.
This commit is contained in:
parent
6de8aa31f3
commit
fda7445ca5
6 changed files with 35 additions and 23 deletions
|
@ -1258,18 +1258,6 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest):
|
|||
with set_recursion_limit(recursion_limit):
|
||||
list(base.glob('**/'))
|
||||
|
||||
def test_glob_recursive_no_trailing_slash(self):
|
||||
P = self.cls
|
||||
p = P(self.base)
|
||||
with self.assertWarns(FutureWarning):
|
||||
p.glob('**')
|
||||
with self.assertWarns(FutureWarning):
|
||||
p.glob('*/**')
|
||||
with self.assertWarns(FutureWarning):
|
||||
p.rglob('**')
|
||||
with self.assertWarns(FutureWarning):
|
||||
p.rglob('*/**')
|
||||
|
||||
def test_glob_pathlike(self):
|
||||
P = self.cls
|
||||
p = P(self.base)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue