Fixed ntpath.expandvars to not replace references to non-existing
variables with nothing. Also added tests.
This fixes bug #494589.
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 @@
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 @@
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