mirror of
https://github.com/python/cpython.git
synced 2025-07-31 07:04:42 +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
|
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).
|
encounter a path we've seen before (meaning that there's a loop).
|
||||||
"""
|
"""
|
||||||
paths_seen = []
|
paths_seen = set()
|
||||||
while islink(path):
|
while islink(path):
|
||||||
if path in paths_seen:
|
if path in paths_seen:
|
||||||
# Already seen this path, so we must have a symlink loop
|
# Already seen this path, so we must have a symlink loop
|
||||||
return None
|
return None
|
||||||
paths_seen.append(path)
|
paths_seen.add(path)
|
||||||
# Resolve where the link points to
|
# Resolve where the link points to
|
||||||
resolved = os.readlink(path)
|
resolved = os.readlink(path)
|
||||||
if not isabs(resolved):
|
if not isabs(resolved):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue