This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brian.curtin
Recipients brian.curtin, ezio.melotti, shura_zam
Date 2010-03-06.16:26:27
SpamBayes Score 5.00866e-12
Marked as misclassified No
Message-id <1267892789.74.0.468004149593.issue6815@psf.upfronthosting.co.za>
In-reply-to
Content
FWIW, _winreg.ExpandEnvironmentStrings does the right thing.

D:\python-dev\trunk>PCbuild\amd64\python.exe
Python 2.7a3+ (trunk, Feb 23 2010, 20:22:24) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, sys, _winreg
>>> os.environ["TEST"] = u"jalape\xf1o".encode(sys.getfilesystemencoding())
>>> print(os.path.expandvars(u"C:\\%TEST%"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\python-dev\trunk\lib\ntpath.py", line 354, in expandvars
    res = res + os.environ[var]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf1 in position 6: ordinal
not in range(128)
>>> print(_winreg.ExpandEnvironmentStrings(u"C:\\%TEST%"))
C:\jalapeño
History
Date User Action Args
2010-03-06 16:26:29brian.curtinsetrecipients: + brian.curtin, shura_zam, ezio.melotti
2010-03-06 16:26:29brian.curtinsetmessageid: <1267892789.74.0.468004149593.issue6815@psf.upfronthosting.co.za>
2010-03-06 16:26:28brian.curtinlinkissue6815 messages
2010-03-06 16:26:27brian.curtincreate