mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
bpo-36035: fix Path.rglob for broken links (GH-11988)
Links creating an infinite symlink loop would raise an exception.
This commit is contained in:
parent
ccb7ca728e
commit
d5c120f7eb
3 changed files with 17 additions and 5 deletions
|
|
@ -1221,7 +1221,8 @@ class _BasePathTest(object):
|
|||
# |-- dirE # No permissions
|
||||
# |-- fileA
|
||||
# |-- linkA -> fileA
|
||||
# `-- linkB -> dirB
|
||||
# |-- linkB -> dirB
|
||||
# `-- brokenLinkLoop -> brokenLinkLoop
|
||||
#
|
||||
|
||||
def setUp(self):
|
||||
|
|
@ -1252,6 +1253,8 @@ class _BasePathTest(object):
|
|||
self.dirlink(os.path.join('..', 'dirB'), join('dirA', 'linkC'))
|
||||
# This one goes upwards, creating a loop.
|
||||
self.dirlink(os.path.join('..', 'dirB'), join('dirB', 'linkD'))
|
||||
# Broken symlink (pointing to itself).
|
||||
os.symlink('brokenLinkLoop', join('brokenLinkLoop'))
|
||||
|
||||
if os.name == 'nt':
|
||||
# Workaround for http://bugs.python.org/issue13772.
|
||||
|
|
@ -1384,7 +1387,7 @@ class _BasePathTest(object):
|
|||
paths = set(it)
|
||||
expected = ['dirA', 'dirB', 'dirC', 'dirE', 'fileA']
|
||||
if support.can_symlink():
|
||||
expected += ['linkA', 'linkB', 'brokenLink']
|
||||
expected += ['linkA', 'linkB', 'brokenLink', 'brokenLinkLoop']
|
||||
self.assertEqual(paths, { P(BASE, q) for q in expected })
|
||||
|
||||
@support.skip_unless_symlink
|
||||
|
|
@ -1465,6 +1468,7 @@ class _BasePathTest(object):
|
|||
'fileA',
|
||||
'linkA',
|
||||
'linkB',
|
||||
'brokenLinkLoop',
|
||||
}
|
||||
self.assertEqual(given, {p / x for x in expect})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue