From: Neal Norwitz Date: Thu, 5 Sep 2002 21:08:25 +0000 (+0000) Subject: SF # 555779, import user doesn't work with CGIs X-Git-Tag: v2.3c1~4208 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=609ba81cdbd18c5af1220f242402dc4c7ac923a4;p=python SF # 555779, import user doesn't work with CGIs --- diff --git a/Lib/posixpath.py b/Lib/posixpath.py index 6c66689b6b..d5d2621c54 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -303,8 +303,10 @@ def expanduser(path): i = i + 1 if i == 1: if not 'HOME' in os.environ: - return path - userhome = os.environ['HOME'] + import pwd + userhome = pwd.getpwuid(os.getuid())[5] + else: + userhome = os.environ['HOME'] else: import pwd try: diff --git a/Lib/user.py b/Lib/user.py index d0cb3ed3df..e550e52ad8 100644 --- a/Lib/user.py +++ b/Lib/user.py @@ -26,6 +26,8 @@ import os home = os.curdir # Default if 'HOME' in os.environ: home = os.environ['HOME'] +elif os.name == 'posix': + home = os.path.expanduser("~/") elif os.name == 'nt': # Contributed by Jeff Bauer if 'HOMEPATH' in os.environ: if 'HOMEDRIVE' in os.environ: