Message61185
os.getcwd() does not use the contents of the PWD
environment variable, much as the glibc getcwd() does
not. This means that if a user sets the path using a
symbolic link, it will be dereferenced before being
passed by os.getcwd().
I propose that get_current_dir_name() be added, either
as a call to the glibc get_current_dir_name(), which
uses the PWD environment variable and therefore will
not dereference symbolic links in the path, or as a
fallback to this Pure Python function:
def get_current_dir_name():
cwd = os.getcwd()
try:
pwd = os.environ["PWD"]
except KeyError:
return cwd
cwd_stat, pwd_stat = map(os.stat, [cwd, pwd])
if cwd_stat.st_dev == pwd_stat.st_dev and
cwd_stat.st_ino == pwd_stat.st_ino:
return pwd
else:
return cwd
|
|
Date |
User |
Action |
Args |
2008-01-20 09:59:38 | admin | link | issue1154351 messages |
2008-01-20 09:59:38 | admin | create | |
|