aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-02-09 18:35:45 -0500
committerEli Schwartz <eschwartz@archlinux.org>2022-02-15 23:51:46 -0500
commit078175314a7b0a2b7db00991e5161d9432d96213 (patch)
tree7ed556147921bc4bbe0a480ad9472ef2b20e7a7d /mesonbuild
parent00aa43d267244bf634faee8fe8a9f52ed8b6b1ff (diff)
downloadmeson-078175314a7b0a2b7db00991e5161d9432d96213.zip
meson-078175314a7b0a2b7db00991e5161d9432d96213.tar.gz
meson-078175314a7b0a2b7db00991e5161d9432d96213.tar.bz2
fine-tune the logic for reporting context on tracebacks
Do not report a MesonBugException if the command is `runpython`, because that is 100% other people's code, not ours. It's only used as an alternative to sys.executable for reporting a path to python, in the event of a Windows MSI install. While we are at it, refactor the logic for PermissionError to be a bit more unified (and sadly use isinstance instead of except, but it is what it is).
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/mesonmain.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index ddb8487..7a4e421 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -155,21 +155,23 @@ class CommandLineParser:
if os.environ.get('MESON_FORCE_BACKTRACE'):
raise
return 1
- except PermissionError:
- if os.environ.get('MESON_FORCE_BACKTRACE'):
- raise
- traceback.print_exc()
- return 2
except Exception as e:
if os.environ.get('MESON_FORCE_BACKTRACE'):
raise
traceback.print_exc()
- 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)
+ # We assume many types of traceback are Meson logic bugs, but most
+ # particularly anything coming from the interpreter during `setup`.
+ # Some things definitely aren't:
+ # - PermissionError is always a problem in the user environment
+ # - runpython doesn't run Meson's own code, even though it is
+ # dispatched by our run()
+ if command != 'runpython' and not isinstance(e, PermissionError):
+ 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
finally:
if pending_python_deprecation_notice: