mirror of
https://github.com/python/cpython.git
synced 2025-12-09 10:37:17 +00:00
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:
parent
b378d991f8
commit
cb88ae635e
3 changed files with 18 additions and 20 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue