fix regression in logging runpython errors

In commit fa044e011d we caught OSError and
started emitting a special error message disclaiming that it probably
isn't Meson's fault, and skipping the generic "This is a meson bug and
should be reported" handler.

But, we no longer did this after verifying that the command *isn't*
runpython, so arbitrary scripts that raised OSError would start saying
stuff about Meson, which was wrong.

Start checking for runpython first.
This commit is contained in:
Eli Schwartz 2022-09-22 14:49:14 -04:00
parent 28103614ef
commit 389b2f6785
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
1 changed files with 9 additions and 8 deletions

View File

@ -49,7 +49,9 @@ def errorhandler(e, command):
raise e
traceback.print_exc()
if isinstance(e, OSError):
if command == 'runpython':
return 2
elif isinstance(e, OSError):
error_msg = os.linesep.join([
"Unhandled python exception",
f"{e.strerror} - {e.args}",
@ -58,13 +60,12 @@ def errorhandler(e, command):
mlog.exception(error_msg)
return e.errno
else: # Exception
if command != 'runpython':
msg = 'Unhandled python exception'
if all(getattr(e, a, None) is not None for a in ['file', 'lineno', 'colno']):
e = MesonBugException(msg, e.file, e.lineno, e.colno) # type: ignore
else:
e = MesonBugException(msg)
mlog.exception(e)
msg = 'Unhandled python exception'
if all(getattr(e, a, None) is not None for a in ['file', 'lineno', 'colno']):
e = MesonBugException(msg, e.file, e.lineno, e.colno) # type: ignore
else:
e = MesonBugException(msg)
mlog.exception(e)
return 2
# Note: when adding arguments, please also add them to the completion