mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
excellent place to use a set() #5069
This commit is contained in:
parent
d081abc8be
commit
1763f8adb4
1 changed files with 2 additions and 2 deletions
|
@ -369,12 +369,12 @@ def _resolve_link(path):
|
|||
until we either arrive at something that isn't a symlink, or
|
||||
encounter a path we've seen before (meaning that there's a loop).
|
||||
"""
|
||||
paths_seen = []
|
||||
paths_seen = set()
|
||||
while islink(path):
|
||||
if path in paths_seen:
|
||||
# Already seen this path, so we must have a symlink loop
|
||||
return None
|
||||
paths_seen.append(path)
|
||||
paths_seen.add(path)
|
||||
# Resolve where the link points to
|
||||
resolved = os.readlink(path)
|
||||
if not isabs(resolved):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue