summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Salter <jsalter@iress.com.au>2015-07-17 16:37:32 +0100
committerJames Salter <jsalter@iress.com.au>2015-07-17 16:37:32 +0100
commitdc030e6c9e718de75579475887e757ec1b434d26 (patch)
tree5f44563adb399cb02a59d53f7c6e5c46e1538313
parent6ea6049b762eb74135ac3069efa39dc46cfc2577 (diff)
downloadnumpy-dc030e6c9e718de75579475887e757ec1b434d26.tar.gz
restrict to windows py3 and add comment
-rw-r--r--numpy/distutils/exec_command.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py
index bda20bd93..f751a8ca3 100644
--- a/numpy/distutils/exec_command.py
+++ b/numpy/distutils/exec_command.py
@@ -395,13 +395,24 @@ def _exec_command( command, use_shell=None, use_tee = None, **env ):
log.debug('Running %s(%s,%r,%r,os.environ)' \
% (spawn_command.__name__, os.P_WAIT, argv[0], argv))
- encoded_environ = {}
- for k, v in os.environ.items():
- try:
- encoded_environ[k.encode(sys.getfilesystemencoding())] = v.encode(
- sys.getfilesystemencoding())
- except UnicodeEncodeError:
- log.debug("ignoring un-encodable env entry %s", k)
+ if sys.version_info[0] >= 3 and os.name == 'nt':
+ # Pre-encode os.environ, discarding un-encodable entries,
+ # to avoid it failing during encoding as part of spawn. Failure
+ # is possible if the environment contains entries that are not
+ # encoded using the system codepage as windows expects.
+ #
+ # This is not necessary on unix, where os.environ is encoded
+ # using the surrogateescape error handler and decoded using
+ # it as part of spawn.
+ encoded_environ = {}
+ for k, v in os.environ.items():
+ try:
+ encoded_environ[k.encode(sys.getfilesystemencoding())] = v.encode(
+ sys.getfilesystemencoding())
+ except UnicodeEncodeError:
+ log.debug("ignoring un-encodable env entry %s", k)
+ else:
+ encoded_environ = os.environ
argv0 = argv[0]
if not using_command: