mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +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
|
@ -959,7 +959,7 @@ class Path(WritablePath, ReadablePath, PurePath):
|
|||
globber = _StringGlobber(self.parser.sep, case_sensitive, case_pedantic, recursive)
|
||||
select = globber.selector(parts[::-1])
|
||||
root = str(self)
|
||||
paths = select(root)
|
||||
paths = select(self.parser.join(root, ''))
|
||||
|
||||
# Normalize results
|
||||
if root == '.':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue