diff options
author | Sjoerd Mullender <sjoerd@acm.org> | 2007-01-16 16:42:38 (GMT) |
---|---|---|
committer | Sjoerd Mullender <sjoerd@acm.org> | 2007-01-16 16:42:38 (GMT) |
commit | 33a0a06d318a3d7164f6269c209b2309781af767 (patch) | |
tree | 88f61b958cde2b25523598a1ee9486ce6fd66074 /Lib/ntpath.py | |
parent | fa3d08b4a92d8af3ec458137393b151a1a0b4391 (diff) | |
download | cpython-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.py | 8 |
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 |