summaryrefslogtreecommitdiffstats
path: root/Lib/ntpath.py
diff options
context:
space:
mode:
authorSjoerd Mullender <sjoerd@acm.org>2007-01-16 16:42:38 (GMT)
committerSjoerd Mullender <sjoerd@acm.org>2007-01-16 16:42:38 (GMT)
commit33a0a06d318a3d7164f6269c209b2309781af767 (patch)
tree88f61b958cde2b25523598a1ee9486ce6fd66074 /Lib/ntpath.py
parentfa3d08b4a92d8af3ec458137393b151a1a0b4391 (diff)
downloadcpython-33a0a06d318a3d7164f6269c209b2309781af767.zip
cpython-33a0a06d318a3d7164f6269c209b2309781af767.tar.gz
cpython-33a0a06d318a3d7164f6269c209b2309781af767.tar.bz2
Fixed ntpath.expandvars to not replace references to non-existing
variables with nothing. Also added tests. This fixes bug #494589.
Diffstat (limited to 'Lib/ntpath.py')
-rw-r--r--Lib/ntpath.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index b32ec16..23d5127 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -344,8 +344,10 @@ def expandvars(path):
var = path[:index]
if var in os.environ:
res = res + os.environ[var]
+ else:
+ res = res + '${' + var + '}'
except ValueError:
- res = res + path
+ res = res + '${' + path
index = pathlen - 1
else:
var = ''
@@ -357,8 +359,10 @@ def expandvars(path):
c = path[index:index + 1]
if var in os.environ:
res = res + os.environ[var]
+ else:
+ res = res + '$' + var
if c != '':
- res = res + c
+ index = index - 1
else:
res = res + c
index = index + 1