Commit 8c031e17 authored by Steve Dower's avatar Steve Dower

Issue #27048: Prevents distutils failing on Windows when environment variables...

Issue #27048: Prevents distutils failing on Windows when environment variables contain non-ASCII characters
parents 089c6f4f 7b9d0828
...@@ -86,11 +86,9 @@ def _get_vc_env(plat_spec): ...@@ -86,11 +86,9 @@ def _get_vc_env(plat_spec):
try: try:
out = subprocess.check_output( out = subprocess.check_output(
'"{}" {} && set'.format(vcvarsall, plat_spec), 'cmd /u /c "{}" {} && set'.format(vcvarsall, plat_spec),
shell=True,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
universal_newlines=True, ).decode('utf-16le', errors='replace')
)
except subprocess.CalledProcessError as exc: except subprocess.CalledProcessError as exc:
log.error(exc.output) log.error(exc.output)
raise DistutilsPlatformError("Error executing {}" raise DistutilsPlatformError("Error executing {}"
......
...@@ -83,6 +83,24 @@ class msvccompilerTestCase(support.TempdirManager, ...@@ -83,6 +83,24 @@ class msvccompilerTestCase(support.TempdirManager,
self.assertFalse(os.path.isfile(os.path.join( self.assertFalse(os.path.isfile(os.path.join(
tempdir, os.path.basename(dll)))) tempdir, os.path.basename(dll))))
def test_get_vc_env_unicode(self):
import distutils._msvccompiler as _msvccompiler
test_var = 'ṰḖṤṪ┅ṼẨṜ'
test_value = '₃⁴₅'
# Ensure we don't early exit from _get_vc_env
old_distutils_use_sdk = os.environ.pop('DISTUTILS_USE_SDK', None)
os.environ[test_var] = test_value
try:
env = _msvccompiler._get_vc_env('x86')
self.assertIn(test_var.lower(), env)
self.assertEqual(test_value, env[test_var.lower()])
finally:
os.environ.pop(test_var)
if old_distutils_use_sdk:
os.environ['DISTUTILS_USE_SDK'] = old_distutils_use_sdk
def test_suite(): def test_suite():
return unittest.makeSuite(msvccompilerTestCase) return unittest.makeSuite(msvccompilerTestCase)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment