diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-12-18 15:17:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-18 15:17:56 (GMT) |
commit | 17d0c0595e101c4ce76b58e55de37e6b5083e6cd (patch) | |
tree | e3e1374312f58fcd88dcd0c22df73f77cdf9d56c /Lib/distutils/util.py | |
parent | e6b247c8e524dbe5fc03b3492f628d0d5348bc49 (diff) | |
download | cpython-17d0c0595e101c4ce76b58e55de37e6b5083e6cd.zip cpython-17d0c0595e101c4ce76b58e55de37e6b5083e6cd.tar.gz cpython-17d0c0595e101c4ce76b58e55de37e6b5083e6cd.tar.bz2 |
bpo-10496: distutils check_environ() handles getpwuid() error (GH-10931)
check_environ() of distutils.utils now catchs KeyError on calling
pwd.getpwuid(): don't create the HOME environment variable in this
case.
Diffstat (limited to 'Lib/distutils/util.py')
-rw-r--r-- | Lib/distutils/util.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py index 8368262..30a21e4 100644 --- a/Lib/distutils/util.py +++ b/Lib/distutils/util.py @@ -157,8 +157,13 @@ def check_environ (): return if os.name == 'posix' and 'HOME' not in os.environ: - import pwd - os.environ['HOME'] = pwd.getpwuid(os.getuid())[5] + try: + import pwd + os.environ['HOME'] = pwd.getpwuid(os.getuid())[5] + except (ImportError, KeyError): + # bpo-10496: if the current user identifier doesn't exist in the + # password database, do nothing + pass if 'PLAT' not in os.environ: os.environ['PLAT'] = get_platform() |