Yury V. Zaytsev added the comment:
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?
----------
nosy: +zaytsev
type: -> behavior
versions: +Python 3.4
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue20164>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com