diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -114,6 +114,7 @@ def _safe_realpath(path): try: return realpath(path) except OSError: + # ignore error, e.g. if the current directory was removed return path if sys.executable: @@ -182,7 +183,13 @@ def _get_default_scheme(): def _getuserbase(): env_base = os.environ.get("PYTHONUSERBASE", None) def joinuser(*args): - return os.path.expanduser(os.path.join(*args)) + path = os.path.join(*args) + try: + return os.path.expanduser(path) + except KeyError: + # ignore pwd.getpwuid() error: the HOME environment variable is not + # set and the current user has not entry in /etc/passwd + pass # what about 'os2emx', 'riscos' ? if os.name == "nt": @@ -485,6 +492,7 @@ def get_config_vars(*args): _init_non_posix(_CONFIG_VARS) if os.name == 'posix': _init_posix(_CONFIG_VARS) + # Setting 'userbase' is done below the call to the # init function to enable using 'get_config_var' in # the init-function.