diff options
author | Dima Pasechnik <dima@pasechnik.info> | 2018-11-17 18:19:52 +0000 |
---|---|---|
committer | Dima Pasechnik <dima@pasechnik.info> | 2018-11-17 18:19:52 +0000 |
commit | 346fde2a542dcb20a7e18a754cc99c48e498bc3e (patch) | |
tree | 32b680e13e3cc3e76539471ebab91aaefb163872 /numpy/distutils/exec_command.py | |
parent | a4b96ad7649281de2c3a41292fcbab4c77c0743d (diff) | |
download | numpy-346fde2a542dcb20a7e18a754cc99c48e498bc3e.tar.gz |
fall back to 'ascii' locale in build (if needed)
If locale.getpreferredencoding(False) returns Null,
the build fails, since commit 5652b0785.
This seems to be not really necessary; here we
provide a fallback to 'ascii' locale if needed.
Diffstat (limited to 'numpy/distutils/exec_command.py')
-rw-r--r-- | numpy/distutils/exec_command.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index af7810d75..f2916d24f 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -67,8 +67,10 @@ def filepath_from_subprocess_output(output): Inherited from `exec_command`, and possibly incorrect. """ - output = output.decode(locale.getpreferredencoding(False), - errors='replace') + mylocale = locale.getpreferredencoding(False) + if mylocale is None: + mylocale = 'ascii' + output = output.decode(mylocale, errors='replace') output = output.replace('\r\n', '\n') # Another historical oddity if output[-1:] == '\n': @@ -278,9 +280,10 @@ def _exec_command(command, use_shell=None, use_tee = None, **env): return 127, '' text, err = proc.communicate() - text = text.decode(locale.getpreferredencoding(False), - errors='replace') - + mylocale = locale.getpreferredencoding(False) + if mylocale is None: + mylocale = 'ascii' + text = text.decode(mylocale, errors='replace') text = text.replace('\r\n', '\n') # Another historical oddity if text[-1:] == '\n': |