Skip to content

Commit

Permalink
Tiny speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Jan 19, 2024
1 parent b9e6b05 commit 3eb53bc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Lib/pathlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,16 @@ def as_uri(self):
def _pattern_parts(self):
"""List of path components, to be used with patterns in glob()."""
parts = self._tail.copy()
if self._raw_path.endswith('**'):
pattern = self._raw_path
if pattern.endswith('**'):
# GH-70303: '**' only matches directories. Add trailing slash.
warnings.warn(
"Pattern ending '**' will match files and directories in a "
"future Python release. Add a trailing slash to match only "
"directories and remove this warning.",
FutureWarning, 4)
parts.append('')
elif self._raw_path[-1] in (self.pathmod.sep, self.pathmod.altsep):
elif pattern[-1] in (self.pathmod.sep, self.pathmod.altsep):
# GH-65238: pathlib doesn't preserve trailing slash. Add it back.
parts.append('')
return parts
Expand Down

0 comments on commit 3eb53bc

Please sign in to comment.