[Python-Dev] ntpath r54364 (was: PEP 370, open questions) (original) (raw)
Paul Moore p.f.moore at gmail.com
Thu Jan 17 18:32:18 CET 2008
- Previous message: [Python-Dev] PEP 370, open questions
- Next message: [Python-Dev] ntpath r54364 (was: PEP 370, open questions)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 17/01/2008, Tim Golden <mail at timgolden.me.uk> wrote:
Ummm... see my earlier point a few posts back which refers to r54364 which gave priority to USERPROFILE over HOMEDRIVE/HOMEPATH
Sorry. I'd not realised this was a post-2.5 revision (ie, not in released code yet...)
Looking at the change, it appears that the point is to support ~user, which it does by getting the current user's home, and replacing the last part, on the assumption that it is the user name.
This works for USERPROFILE (in my experience, I don't know if there are corner cases where it isn't true) but does not work if HOME is set, and only works otherwise by preferring USERPROFILE over HOMEDRIVE/HOMEPATH (and I believe that preference is misleading, as USERPROFILE is always set if HOMEDRIVE/PATH is, so there's no point checking for HD/HP if USERDIR fails).
I'd recommend that this change be reverted. To correctly get another user's home directory would involve reading (via the registry, or maybe some utility function I couldn't find at a quick glance) the value of HOMEDRIVE/HOMEPATH which is set for the other user. (In fact, given that I guess these could be set in a login script, it's entirely possible that the information simply isn't available).
I don't believe that ~user is a useful concept on Windows, and I'd rather that code using it fail than give what are quite probably unreliable answers.
If someone wants to support user where user is the name of the
current user, then that could be covered by an explicit check that the
name matches, and if so use the code for '', but personally I don't
think that's worth it.
Paul.
- Previous message: [Python-Dev] PEP 370, open questions
- Next message: [Python-Dev] ntpath r54364 (was: PEP 370, open questions)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]