This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zaytsev
Recipients acdha, zaytsev
Date 2014-01-07.16:38:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Amusingly, it's also the case on BG/Q compute nodes. Only this morning, I cooked up the following patch:

--- a/Lib/
+++ b/Lib/
@@ -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)
             userhome = os.environ['HOME']

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:31zaytsevsetrecipients: + zaytsev, acdha
2014-01-07 16:38:31zaytsevsetmessageid: <>
2014-01-07 16:38:31zaytsevlinkissue20164 messages
2014-01-07 16:38:30zaytsevcreate