Message207555
Amusingly, it's also the case on BG/Q compute nodes. Only this morning, I cooked up the following patch:
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -237,7 +237,11 @@ def expanduser(path):
if i == 1:
if 'HOME' not in os.environ:
import pwd
- userhome = pwd.getpwuid(os.getuid()).pw_dir
+ try:
+ userhome = pwd.getpwuid(os.getuid()).pw_dir
+ except KeyError:
+ import warnings
+ warnings.warn('Unable to auto-detect $HOME, export it or functionality such as user-installed modules will not work!', RuntimeWarning)
else:
userhome = os.environ['HOME']
else:
I think it's a bit harsh to fail completely, but returning silently also doesn't sound like a good idea, so I decided to issue a warning instead; the wording should be probably tweaked by a native speaker of English though.
What do you think? |
|
Date |
User |
Action |
Args |
2014-01-07 16:38:31 | zaytsev | set | recipients:
+ zaytsev, acdha |
2014-01-07 16:38:31 | zaytsev | set | messageid: <1389112711.04.0.0491878764522.issue20164@psf.upfronthosting.co.za> |
2014-01-07 16:38:31 | zaytsev | link | issue20164 messages |
2014-01-07 16:38:30 | zaytsev | create | |
|