GH-104102: Optimize pathlib.Path.glob() handling of ../ pattern segments (GH-104103)

These segments do not require a `stat()` call, as the selector's
`_select_from()` method is called after we've established that the
parent is a directory.
This commit is contained in:
Barney Gale 2023-05-03 00:16:04 +01:00 committed by GitHub
parent 47770a1e91
commit 65a49c6553
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View file

@ -1892,8 +1892,13 @@ def test_glob_dotdot(self):
P = self.cls
p = P(BASE)
self.assertEqual(set(p.glob("..")), { P(BASE, "..") })
self.assertEqual(set(p.glob("../..")), { P(BASE, "..", "..") })
self.assertEqual(set(p.glob("dirA/..")), { P(BASE, "dirA", "..") })
self.assertEqual(set(p.glob("dirA/../file*")), { P(BASE, "dirA/../fileA") })
self.assertEqual(set(p.glob("dirA/../file*/..")), set())
self.assertEqual(set(p.glob("../xyzzy")), set())
self.assertEqual(set(p.glob("xyzzy/..")), set())
self.assertEqual(set(p.glob("/".join([".."] * 50))), { P(BASE, *[".."] * 50)})
@os_helper.skip_unless_symlink
def test_glob_permissions(self):