mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
GH-129835: Yield path with trailing slash from ReadablePath.glob('')
(#129836)
In the private pathlib ABCs, make `ReadablePath.glob('')` yield a path with a trailing slash (if it yields anything at all). As a result, `glob()` works similarly to `joinpath()` when given a non-magic pattern. In the globbing implementation, we preemptively add trailing slashes to intermediate paths if there are pattern parts remaining; this removes the need to check for existing trailing slashes (in the removed `add_slash()` method) at subsequent steps.
This commit is contained in:
parent
6c67904e79
commit
707d066193
4 changed files with 15 additions and 30 deletions
|
@ -460,7 +460,7 @@ class ReadablePath(JoinablePath):
|
|||
recursive = True if recurse_symlinks else _no_recurse_symlinks
|
||||
globber = _PathGlobber(self.parser.sep, case_sensitive, case_pedantic, recursive)
|
||||
select = globber.selector(parts)
|
||||
return select(self)
|
||||
return select(self.joinpath(''))
|
||||
|
||||
def rglob(self, pattern, *, case_sensitive=None, recurse_symlinks=True):
|
||||
"""Recursively yield all existing files (of any kind, including
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue