Skip to content

Commit

Permalink
Merge pull request #20463 from charris/backport-20353
Browse files Browse the repository at this point in the history
BUG, DIST: Print os error message when the executable not exist
  • Loading branch information
charris committed Nov 26, 2021
2 parents 884c6c8 + dcd529a commit 87d6f96
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions numpy/distutils/ccompiler.py
Expand Up @@ -143,12 +143,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
Expand Down
4 changes: 2 additions & 2 deletions numpy/distutils/ccompiler_opt.py
Expand Up @@ -708,8 +708,8 @@ def _dist_test_spawn(cmd, display=None):
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
Expand Down

0 comments on commit 87d6f96

Please sign in to comment.