diff options
author | Johannes Gijsbers <jlg@dds.nl> | 2004-08-30 10:19:56 (GMT) |
---|---|---|
committer | Johannes Gijsbers <jlg@dds.nl> | 2004-08-30 10:19:56 (GMT) |
commit | ae882f798435266b41a9c8966562102345a3eda5 (patch) | |
tree | 56f865bf36c127b6702fa53a5ad72daca0fa6570 /Lib/macpath.py | |
parent | d3f61a2de6a9664dde5f98b5d0acdef7a73948dc (diff) | |
download | cpython-ae882f798435266b41a9c8966562102345a3eda5.zip cpython-ae882f798435266b41a9c8966562102345a3eda5.tar.gz cpython-ae882f798435266b41a9c8966562102345a3eda5.tar.bz2 |
Patch #941486: add os.path.lexists(). Also fix bug #940578 by using lexists in glob.glob.
Diffstat (limited to 'Lib/macpath.py')
-rw-r--r-- | Lib/macpath.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/macpath.py b/Lib/macpath.py index 1d3fa56..bca410e 100644 --- a/Lib/macpath.py +++ b/Lib/macpath.py @@ -150,7 +150,7 @@ def getctime(filename): return os.stat(filename).st_ctime def exists(s): - """Return True if the pathname refers to an existing file or directory.""" + """Test whether a path exists. Returns False for broken symbolic links""" try: st = os.stat(s) @@ -158,6 +158,18 @@ def exists(s): return False return True +# Is `stat`/`lstat` a meaningful difference on the Mac? This is safe in any +# case. + +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 + # Return the longest prefix of all list elements. def commonprefix(m): |