Fixed ntpath.expandvars to not replace references to non-existing

variables with nothing.  Also added tests.
This fixes bug #494589.
This commit is contained in:
Sjoerd Mullender 2007-01-16 16:42:38 +00:00
parent fa3d08b4a9
commit 33a0a06d31
4 changed files with 32 additions and 2 deletions

View file

@ -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