diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-10-09 15:15:39 -0700 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-11-13 00:40:13 +0200 |
commit | de175aac0051b5625e21aeb5b9864ae7c376f9d7 (patch) | |
tree | 0b81d8364ccc058c31f9a89db6f3e1bfefd59f4d /mesonbuild/compilers/d.py | |
parent | cecad3b9dbe06945c5131570bec9ce1406f4fb8a (diff) | |
download | meson-de175aac0051b5625e21aeb5b9864ae7c376f9d7.zip meson-de175aac0051b5625e21aeb5b9864ae7c376f9d7.tar.gz meson-de175aac0051b5625e21aeb5b9864ae7c376f9d7.tar.bz2 |
compilers: Use keyword only arguments for compiler interfaces
Because we need to inherit them in some cases, and python's
keyword-or-positional arguments make this really painful, especially
with inheritance. They do this in two ways:
1) If you want to intercept the arguments you need to check for both a
keyword and a positional argument, because you could get either. Then
you need to make sure that you only pass one of those down to the
next layer.
2) After you do that, if the layer below you decides to do the same
thing, but uses the other form (you used keyword by the lower level
uses positional or vice versa), then you'll get a TypeError since two
layers down got the argument as both a positional and a keyword.
All of this is bad. Fortunately python 3.x provides a mechanism to solve
this, keyword only arguments. These arguments cannot be based
positionally, the interpreter will give us an error in that case.
I have made a best effort to do this correctly, and I've verified it
with GCC, Clang, ICC, and MSVC, but there are other compilers like Arm
and Elbrus that I don't have access to.
Diffstat (limited to 'mesonbuild/compilers/d.py')
-rw-r--r-- | mesonbuild/compilers/d.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index 0a59e7f..2cf0fbd 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -303,7 +303,7 @@ class DCompiler(Compiler): args += extra_args return args - def compiles(self, code, env, extra_args=None, dependencies=None, mode='compile'): + def compiles(self, code, env, *, extra_args=None, dependencies=None, mode='compile'): args = self._get_compiler_check_args(env, extra_args, dependencies, mode) with self.compile(code, args, mode) as p: |