diff options
author | Tyler Reddy <tyler.je.reddy@gmail.com> | 2018-09-10 09:35:45 -0700 |
---|---|---|
committer | Tyler Reddy <tyler.je.reddy@gmail.com> | 2018-09-10 09:36:12 -0700 |
commit | ac7dc482b2292c1987412ea7742f948681982f18 (patch) | |
tree | 5e5e33b6a2d17acaa46170a951edabc6bc93a78e /numpy/distutils/exec_command.py | |
parent | 91454d6611021cc1d0d581f7bc81775ca0184517 (diff) | |
download | numpy-ac7dc482b2292c1987412ea7742f948681982f18.tar.gz |
MAINT: remove exec_command from gnu.py
* replaced usage of exec_command() with
standard library equivalent in distutils
gnu module
Diffstat (limited to 'numpy/distutils/exec_command.py')
-rw-r--r-- | numpy/distutils/exec_command.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index 8118e2fc3..af7810d75 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -61,6 +61,24 @@ import locale from numpy.distutils.misc_util import is_sequence, make_temp_file from numpy.distutils import log +def filepath_from_subprocess_output(output): + """ + Convert `bytes` in the encoding used by a subprocess into a filesystem-appropriate `str`. + + Inherited from `exec_command`, and possibly incorrect. + """ + output = output.decode(locale.getpreferredencoding(False), + errors='replace') + output = output.replace('\r\n', '\n') + # Another historical oddity + if output[-1:] == '\n': + output = output[:-1] + # stdio uses bytes in python 2, so to avoid issues, we simply + # remove all non-ascii characters + if sys.version_info < (3, 0): + output = output.encode('ascii', errors='replace') + return output + def temp_file_name(): fo, name = make_temp_file() fo.close() |