Mercurial > hg-stable
changeset 15353:ab600a25dfc0 stable
posix: workaround for os.path.realpath bug in Python 2.4.1 and before
os.path.realpath didn't resolve symlinks that were the first component of
the path, see http://bugs.python.org/issue1213894
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Mon, 24 Oct 2011 13:32:23 +0200 |
parents | b74f74b482d8 |
children | 42630f54e513 |
files | mercurial/posix.py |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/posix.py Mon Oct 24 10:08:58 2011 +0200 +++ b/mercurial/posix.py Mon Oct 24 13:32:23 2011 +0200 @@ -199,6 +199,14 @@ return fcntl.fcntl(fd, F_GETPATH, '\0' * 1024).rstrip('\0') finally: os.close(fd) +elif sys.version_info < (2, 4, 2, 'final'): + # Workaround for http://bugs.python.org/issue1213894 (os.path.realpath + # didn't resolve symlinks that were the first component of the path.) + def realpath(path): + if os.path.isabs(path): + return os.path.realpath(path) + else: + return os.path.realpath('./' + path) else: # Fallback to the likely inadequate Python builtin function. realpath = os.path.realpath