mirror of
https://github.com/python/cpython.git
synced 2025-10-31 21:51:50 +00:00
GH-106330: Fix matching of empty path in pathlib.PurePath.match() (GH-106331)
We match paths using the `_lines` attribute, which is derived from the path's string representation. The bug arises because an empty path's string representation is `'.'` (not `''`), which is matched by the `'*'` wildcard.
This commit is contained in:
parent
e5862113dd
commit
b4efdf8cda
3 changed files with 12 additions and 2 deletions
|
|
@ -463,8 +463,12 @@ def _lines(self):
|
|||
try:
|
||||
return self._lines_cached
|
||||
except AttributeError:
|
||||
trans = _SWAP_SEP_AND_NEWLINE[self._flavour.sep]
|
||||
self._lines_cached = str(self).translate(trans)
|
||||
path_str = str(self)
|
||||
if path_str == '.':
|
||||
self._lines_cached = ''
|
||||
else:
|
||||
trans = _SWAP_SEP_AND_NEWLINE[self._flavour.sep]
|
||||
self._lines_cached = path_str.translate(trans)
|
||||
return self._lines_cached
|
||||
|
||||
def __eq__(self, other):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue