From 0a432f14e07c06516a9f8cd06b1fbcc18da68abf Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Thu, 25 Apr 2024 14:37:05 -0500 Subject: [PATCH] Catch Python exception in the event alignment can't be converted to int The user almost certainly has to be using a compiler wrapper script that doesn't actually work if we land here. Fixes: #12982 --- mesonbuild/compilers/mixins/clike.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py index ac2344bf857e..b7c2f06b5885 100644 --- a/mesonbuild/compilers/mixins/clike.py +++ b/mesonbuild/compilers/mixins/clike.py @@ -625,9 +625,17 @@ def alignment(self, typename: str, prefix: str, env: 'Environment', *, raise mesonlib.EnvironmentException('Could not compile alignment test.') if res.returncode != 0: raise mesonlib.EnvironmentException('Could not run alignment test binary.') - align = int(res.stdout) - if align == 0: - raise mesonlib.EnvironmentException(f'Could not determine alignment of {typename}. Sorry. You might want to file a bug.') + + align: int + try: + align = int(res.stdout) + if align == 0: + raise mesonlib.EnvironmentException(f'Could not determine alignment of {typename}. Sorry. You might want to file a bug.') + except ValueError: + # If we get here, the user is most likely using a script that is + # pretending to be a compiler. + raise mesonlib.EnvironmentException('Could not run alignment test binary.') + return align, res.cached def get_define(self, dname: str, prefix: str, env: 'Environment',