diff options
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/interpreter.py | 2 | ||||
-rw-r--r-- | mesonbuild/interpreterbase.py | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 7e5ad27..2b27694 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3810,7 +3810,7 @@ different subdirectory. @stringArgs @noKwargs def func_join_paths(self, node, args, kwargs): - return os.path.join(*args).replace('\\', '/') + return self.join_path_strings(args) def run(self): super().run() diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index aee1c87..66e9dd6 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -382,6 +382,9 @@ class InterpreterBase: me.file = environment.build_filename raise me + def join_path_strings(self, args): + return os.path.join(*args).replace('\\', '/') + def parse_project(self): """ Parses project() and initializes languages, compilers etc. Do this @@ -628,9 +631,13 @@ The result of this is undefined and will become a hard error in a future Meson r raise InvalidCode('Multiplication works only with integers.') return l * r elif cur.operation == 'div': - if not isinstance(l, int) or not isinstance(r, int): - raise InvalidCode('Division works only with integers.') - return l // r + if isinstance(l, str) and isinstance(r, str): + return self.join_path_strings((l, r)) + if isinstance(l, int) and isinstance(r, int): + if r == 0: + raise InvalidCode('Division by zero.') + return l // r + raise InvalidCode('Division works only with strings or integers.') elif cur.operation == 'mod': if not isinstance(l, int) or not isinstance(r, int): raise InvalidCode('Modulo works only with integers.') |