Skip to content

Commit 4978118

Browse files
authored
Merge pull request numpy#20353 from seiko2plus/issue_20335
BUG, DIST: Print os error message when the executable not exist
2 parents bbe51bd + 6d69886 commit 4978118

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

numpy/distutils/ccompiler.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,18 @@ def CCompiler_spawn(self, cmd, display=None):
144144
except subprocess.CalledProcessError as exc:
145145
o = exc.output
146146
s = exc.returncode
147-
except OSError:
147+
except OSError as e:
148148
# OSError doesn't have the same hooks for the exception
149149
# output, but exec_command() historically would use an
150150
# empty string for EnvironmentError (base class for
151151
# OSError)
152-
o = b''
152+
# o = b''
153+
# still that would make the end-user lost in translation!
154+
o = f"\n\n{e}\n\n\n"
155+
try:
156+
o = o.encode(sys.stdout.encoding)
157+
except AttributeError:
158+
o = o.encode('utf8')
153159
# status previously used by exec_command() for parent
154160
# of OSError
155161
s = 127

numpy/distutils/ccompiler_opt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ def _dist_test_spawn(cmd, display=None):
716716
except subprocess.CalledProcessError as exc:
717717
o = exc.output
718718
s = exc.returncode
719-
except OSError:
720-
o = b''
719+
except OSError as e:
720+
o = e
721721
s = 127
722722
else:
723723
return None

0 commit comments

Comments
 (0)