diff options
author | Guido van Rossum <guido@python.org> | 2016-01-06 10:35:30 -0800 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2016-01-06 10:35:30 -0800 |
commit | 3ffcbf255e3561da215be8080714e84302549f50 (patch) | |
tree | 0ac3c7d2965edfe5cd324475d65a34c9f1f1d04c /Lib/test/test_pathlib.py | |
parent | 3b9157f70d55e1da16ab300c15075721fb0548bb (diff) | |
parent | 8259a0053acdc691022abc5eb773e9431ea96435 (diff) | |
download | cpython-3ffcbf255e3561da215be8080714e84302549f50.tar.gz |
Issue #26012: Don't traverse into symlinks for ** pattern in pathlib.Path.[r]glob(). (Merge 3.4->3.5)
Diffstat (limited to 'Lib/test/test_pathlib.py')
-rw-r--r-- | Lib/test/test_pathlib.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py index be1e04282d..5ee22adb56 100644 --- a/Lib/test/test_pathlib.py +++ b/Lib/test/test_pathlib.py @@ -1241,7 +1241,7 @@ class _BasePathTest(object): os.symlink('non-existing', join('brokenLink')) self.dirlink('dirB', join('linkB')) self.dirlink(os.path.join('..', 'dirB'), join('dirA', 'linkC')) - # This one goes upwards but doesn't create a loop + # This one goes upwards, creating a loop self.dirlink(os.path.join('..', 'dirB'), join('dirB', 'linkD')) if os.name == 'nt': @@ -1437,6 +1437,23 @@ class _BasePathTest(object): _check(p.rglob("file*"), ["dirC/fileC", "dirC/dirD/fileD"]) _check(p.rglob("*/*"), ["dirC/dirD/fileD"]) + @with_symlinks + def test_rglob_symlink_loop(self): + # Don't get fooled by symlink loops (Issue #26012) + P = self.cls + p = P(BASE) + given = set(p.rglob('*')) + expect = {'brokenLink', + 'dirA', 'dirA/linkC', + 'dirB', 'dirB/fileB', 'dirB/linkD', + 'dirC', 'dirC/dirD', 'dirC/dirD/fileD', 'dirC/fileC', + 'dirE', + 'fileA', + 'linkA', + 'linkB', + } + self.assertEqual(given, {p / x for x in expect}) + def test_glob_dotdot(self): # ".." is not special in globs P = self.cls |