[Python-bugs-list] [ python-Bugs-442712 ] os.path.expanduser problem w/o HOME set
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 19 Jul 2001 10:21:13 -0700
Bugs item #442712, was opened at 2001-07-19 04:05
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442712&group_id=5470
Category: Windows
Group: Python 2.1.1
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Tim Peters (tim_one)
Summary: os.path.expanduser problem w/o HOME set
Initial Comment:
If I do a os.path.expanduser("~") I get '\Documents
and Settings\kwg' - the C: drive is not mentioned.
I traced this to the call to join (and onwards to the
isabs call in the code for the join function.
Simple remedy is to use
userhome = drive + os.environ['HOMEPATH']
instead of
userhome = join(drive, os.environ['HOMEPATH']
My sys.version value is
'2.1 (#15, Apr 16 2001, 18:24:49) [MSC 32 bit (Intel]'
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2001-07-19 10:21
Message:
Logged In: YES
user_id=31435
Agree with Guido that ntpath.join was too stupid. Fixed in
Lib/ntpath.py, rev 1.37.
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2001-07-19 07:08
Message:
Logged In: YES
user_id=6380
Well, I think join should be made smarter!
os.path.isabs("\foo") returns 0 because \f is interpreted by
the interpreter as '\x0c'. Try "\foo" or r"\foo" instead.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2001-07-19 06:11
Message:
Logged In: NO
I think the reason why join doesn't work is to do with isabs
returning true when "\foo" is entered as a parameter under
NT - surely the name of the drive must be included if the
parameter doesn't look like a UNC filename?
Inother words, on NT
\foo should fail
//ferrari\foo should not fail
c:\foo should not fail
I've also noticed that os.path.isabs("\foo") returns 0,
os.path.isabs("/foo") returns 1 on Windows 2000. Surely this
should be the other way round?
----------------------------------------------------------------------
Comment By: Guido van Rossum (gvanrossum)
Date: 2001-07-19 05:45
Message:
Logged In: YES
user_id=6380
Hm, but why doesn't the join() work?
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=442712&group_id=5470