GH-102613: Fix recursion error from pathlib.Path.glob() (GH-104373)

Use `Path.walk()` to implement the recursive wildcard `**`. This method
uses an iterative (rather than recursive) walk - see GH-100282.
This commit is contained in:
Barney Gale 2023-05-15 18:33:32 +01:00 committed by GitHub
parent b378d991f8
commit cb88ae635e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 20 deletions

View file

@ -1972,6 +1972,17 @@ class _BasePathTest(object):
bad_link.symlink_to("bad" * 200)
self.assertEqual(sorted(base.glob('**/*')), [bad_link])
def test_glob_above_recursion_limit(self):
recursion_limit = 40
# directory_depth > recursion_limit
directory_depth = recursion_limit + 10
base = pathlib.Path(os_helper.TESTFN, 'deep')
path = pathlib.Path(base, *(['d'] * directory_depth))
path.mkdir(parents=True)
with set_recursion_limit(recursion_limit):
list(base.glob('**'))
def _check_resolve(self, p, expected, strict=True):
q = p.resolve(strict)
self.assertEqual(q, expected)