diff options
author | Omer Pereg <duckflyer@gmail.com> | 2022-07-26 22:09:29 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2022-07-31 14:54:44 +0300 |
commit | fa044e011d5d7a3525c9b3f2acfe1cbf4a0a96a1 (patch) | |
tree | a1fba93678b5fffd96307d1dd8d5e442e931773b | |
parent | 1e1dee738b7eae9e9c22601522798f4945391379 (diff) | |
download | meson-fa044e011d5d7a3525c9b3f2acfe1cbf4a0a96a1.zip meson-fa044e011d5d7a3525c9b3f2acfe1cbf4a0a96a1.tar.gz meson-fa044e011d5d7a3525c9b3f2acfe1cbf4a0a96a1.tar.bz2 |
handle OSError exception in run function
-rw-r--r-- | mesonbuild/mesonmain.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 7589b6c..ec4bfff 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -13,6 +13,7 @@ # limitations under the License. # Work around some pathlib bugs... + from . import _pathlib import sys sys.modules['pathlib'] = _pathlib @@ -158,6 +159,18 @@ class CommandLineParser: if os.environ.get('MESON_FORCE_BACKTRACE'): raise return 1 + except OSError as e: + if os.environ.get('MESON_FORCE_BACKTRACE'): + raise + traceback.print_exc() + error_msg = os.linesep.join([ + "Unhandled python exception", + f"{e.strerror} - {e.args}", + "this is probably not a Meson bug."]) + + mlog.exception(error_msg) + return e.errno + except Exception as e: if os.environ.get('MESON_FORCE_BACKTRACE'): raise @@ -168,7 +181,7 @@ class CommandLineParser: # - 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): + 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 |