mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] GH-106330: Fix matching of empty path in pathlib.PurePath.match()
(GH-106331) (GH-106372)
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.
(cherry picked from commit b4efdf8cda
)
This commit is contained in:
parent
930df7b07e
commit
d5ed72b696
3 changed files with 25 additions and 8 deletions
|
@ -317,6 +317,10 @@ class _BasePurePathTest(object):
|
|||
self.assertTrue(P('A.py').match('a.PY', case_sensitive=False))
|
||||
self.assertFalse(P('c:/a/B.Py').match('C:/A/*.pY', case_sensitive=True))
|
||||
self.assertTrue(P('/a/b/c.py').match('/A/*/*.Py', case_sensitive=False))
|
||||
# Matching against empty path
|
||||
self.assertFalse(P().match('*'))
|
||||
self.assertTrue(P().match('**'))
|
||||
self.assertFalse(P().match('**/*'))
|
||||
|
||||
def test_ordering_common(self):
|
||||
# Ordering is tuple-alike.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue