mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-92550 - Fix regression in pathlib.Path.rglob()
(GH-92583)
We could try to remedy this by taking a slice, but we then run into an issue where the empty string will match altsep on POSIX. That rabbit hole could keep getting deeper.
A proper fix for the original issue involves making pathlib's path normalisation more configurable - in this case we want to retain trailing slashes, but in other we might want to preserve `./` prefixes, or elide `../` segments when we're sure we won't encounter symlinks.
This reverts commit ea2f5bcda1
.
This commit is contained in:
parent
cb35402c18
commit
dcdf250d2d
5 changed files with 2 additions and 38 deletions
|
@ -281,8 +281,6 @@ _posix_flavour = _PosixFlavour()
|
|||
def _make_selector(pattern_parts, flavour):
|
||||
pat = pattern_parts[0]
|
||||
child_parts = pattern_parts[1:]
|
||||
if not pat:
|
||||
return _TerminatingSelector()
|
||||
if pat == '**':
|
||||
cls = _RecursiveWildcardSelector
|
||||
elif '**' in pat:
|
||||
|
@ -945,8 +943,6 @@ class Path(PurePath):
|
|||
drv, root, pattern_parts = self._flavour.parse_parts((pattern,))
|
||||
if drv or root:
|
||||
raise NotImplementedError("Non-relative patterns are unsupported")
|
||||
if pattern[-1] in (self._flavour.sep, self._flavour.altsep):
|
||||
pattern_parts.append('')
|
||||
selector = _make_selector(tuple(pattern_parts), self._flavour)
|
||||
for p in selector.select_from(self):
|
||||
yield p
|
||||
|
@ -960,8 +956,6 @@ class Path(PurePath):
|
|||
drv, root, pattern_parts = self._flavour.parse_parts((pattern,))
|
||||
if drv or root:
|
||||
raise NotImplementedError("Non-relative patterns are unsupported")
|
||||
if pattern[-1] in (self._flavour.sep, self._flavour.altsep):
|
||||
pattern_parts.append('')
|
||||
selector = _make_selector(("**",) + tuple(pattern_parts), self._flavour)
|
||||
for p in selector.select_from(self):
|
||||
yield p
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue