Patch #941486: add os.path.lexists(). Also fix bug #940578 by using lexists in glob.glob.

This commit is contained in:
Johannes Gijsbers 2004-08-30 10:19:56 +00:00
parent d3f61a2de6
commit ae882f7984
11 changed files with 57 additions and 4 deletions

View file

@ -174,6 +174,17 @@ def exists(path):
return True
# Being true for dangling symbolic links is also useful.
def lexists(path):
"""Test whether a path exists. Returns True for broken symbolic links"""
try:
st = os.lstat(path)
except os.error:
return False
return True
# Is a path a directory?
# This follows symbolic links, so both islink() and isdir() can be true
# for the same path.