Feature Requests item #1154351, was opened at 2005-03-01 16:26
Message generated for change (Comment added) made by hoffmanm
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1154351&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael Hoffman (hoffmanm)
Assigned to: Nobody/Anonymous (nobody)
Summary: add get_current_dir_name() to os module
Initial Comment:
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
----------------------------------------------------------------------
>Comment By: Michael Hoffman (hoffmanm)
Date: 2005-03-01 16:27
Message:
Logged In: YES
user_id=987664
Hmmm... my indentation seems to have gone by the wayside.
Still you can probably figure out what the code is supposed
to do <wink>
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1154351&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com