From: Georges Discry Date: Thu, 20 Apr 2023 20:31:45 +0000 (+0200) Subject: Override sys.excepthook when calling main X-Git-Tag: v15~225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1937be34693b12d08c07009dc96d198f8863f266;p=thirdparty%2Fmkosi.git Override sys.excepthook when calling main Overriding `sys.excepthook` with `mkosi.run.excepthook` has to happen when calling `mkosi.__main__.main()`, otherwise it is not applied when `main` is simply imported and then called (by using a zipapp or a console script entry point). --- diff --git a/mkosi/__main__.py b/mkosi/__main__.py index 69c524f11..9e4d1394c 100644 --- a/mkosi/__main__.py +++ b/mkosi/__main__.py @@ -15,6 +15,8 @@ from mkosi.run import excepthook @contextlib.contextmanager def propagate_failed_return() -> Iterator[None]: + sys.excepthook = excepthook + try: yield except SystemExit as e: @@ -58,5 +60,4 @@ def main() -> None: if __name__ == "__main__": - sys.excepthook = excepthook main()