summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2002-09-05 21:08:25 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2002-09-05 21:08:25 (GMT)
commit609ba81cdbd18c5af1220f242402dc4c7ac923a4 (patch)
treec66157c42032d62d7217d353387114ab1718aa81
parentbd9adab13801dcd4826488ac9afbd03c4b3f0ccf (diff)
downloadcpython-609ba81cdbd18c5af1220f242402dc4c7ac923a4.zip
cpython-609ba81cdbd18c5af1220f242402dc4c7ac923a4.tar.gz
cpython-609ba81cdbd18c5af1220f242402dc4c7ac923a4.tar.bz2
SF # 555779, import user doesn't work with CGIs
-rw-r--r--Lib/posixpath.py6
-rw-r--r--Lib/user.py2
2 files changed, 6 insertions, 2 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index 6c66689..d5d2621 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 d0cb3ed..e550e52 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: