diff options
| author | Ralf Gommers <ralf.gommers@gmail.com> | 2021-11-14 09:06:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-14 09:06:01 +0100 |
| commit | 49781189689f4a7bcbb8196257bb1bc477334589 (patch) | |
| tree | 1806ca1d5152979d82b17ab883d065bd45b62fa3 | |
| parent | bbe51bde46cad1ecf1f4cf2c17eb7475d0df8e5d (diff) | |
| parent | 6d698863f6d38e84ae78b6f1aeae1b3d3993ed6b (diff) | |
| download | numpy-49781189689f4a7bcbb8196257bb1bc477334589.tar.gz | |
Merge pull request #20353 from seiko2plus/issue_20335
BUG, DIST: Print os error message when the executable not exist
| -rw-r--r-- | numpy/distutils/ccompiler.py | 10 | ||||
| -rw-r--r-- | numpy/distutils/ccompiler_opt.py | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index 9c85d28b9..713b8c72f 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -144,12 +144,18 @@ def CCompiler_spawn(self, cmd, display=None): except subprocess.CalledProcessError as exc: o = exc.output s = exc.returncode - except OSError: + except OSError as e: # OSError doesn't have the same hooks for the exception # output, but exec_command() historically would use an # empty string for EnvironmentError (base class for # OSError) - o = b'' + # o = b'' + # still that would make the end-user lost in translation! + o = f"\n\n{e}\n\n\n" + try: + o = o.encode(sys.stdout.encoding) + except AttributeError: + o = o.encode('utf8') # status previously used by exec_command() for parent # of OSError s = 127 diff --git a/numpy/distutils/ccompiler_opt.py b/numpy/distutils/ccompiler_opt.py index 85bf5d0d1..39847c20f 100644 --- a/numpy/distutils/ccompiler_opt.py +++ b/numpy/distutils/ccompiler_opt.py @@ -716,8 +716,8 @@ class _Distutils: except subprocess.CalledProcessError as exc: o = exc.output s = exc.returncode - except OSError: - o = b'' + except OSError as e: + o = e s = 127 else: return None |
