summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pathlib.py
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2023-05-15 17:33:32 (GMT)
committerGitHub <noreply@github.com>2023-05-15 17:33:32 (GMT)
commitcb88ae635e96d7020ba6187bcfd45ace4dcd8395 (patch)
tree54a3c649da8786ad5a05ccdc999095a25211d709 /Lib/test/test_pathlib.py
parentb378d991f8cd41c33416e590cb83472cce1d6b98 (diff)
downloadcpython-cb88ae635e96d7020ba6187bcfd45ace4dcd8395.zip
cpython-cb88ae635e96d7020ba6187bcfd45ace4dcd8395.tar.gz
cpython-cb88ae635e96d7020ba6187bcfd45ace4dcd8395.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r--Lib/test/test_pathlib.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
index 67ca479..46a5248 100644
--- a/Lib/test/test_pathlib.py
+++ b/Lib/test/test_pathlib.py
@@ -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)