aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/modules
diff options
context:
space:
mode:
authorMathieu Duponchelle <mathieu@centricular.com>2019-11-10 16:34:08 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2019-11-11 22:39:43 +0200
commit4d51ac32201c694add0680c182ea9ed60559619b (patch)
tree231653b2d507ad00788970fccd919ea2267f71a2 /mesonbuild/modules
parent33a2e7c3d2b18106534709151e651432921962fe (diff)
downloadmeson-4d51ac32201c694add0680c182ea9ed60559619b.zip
meson-4d51ac32201c694add0680c182ea9ed60559619b.tar.gz
meson-4d51ac32201c694add0680c182ea9ed60559619b.tar.bz2
hotdoc: work around argparse syntax ambiguity
Fixes #5800
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r--mesonbuild/modules/hotdoc.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/mesonbuild/modules/hotdoc.py b/mesonbuild/modules/hotdoc.py
index 02e07a9..bf4386f 100644
--- a/mesonbuild/modules/hotdoc.py
+++ b/mesonbuild/modules/hotdoc.py
@@ -81,12 +81,28 @@ class HotdocTargetBuilder:
elif isinstance(value, list):
# Do not do anything on empty lists
if value:
+ # https://bugs.python.org/issue9334 (from 2010 :( )
+ # The syntax with nargs=+ is inherently ambiguous
+ # A workaround for this case is to simply prefix with a space
+ # every value starting with a dash
+ escaped_value = []
+ for e in value:
+ if isinstance(e, str) and e.startswith('-'):
+ escaped_value += [' %s' % e]
+ else:
+ escaped_value += [e]
if option:
- self.cmd.extend([option] + value)
+ self.cmd.extend([option] + escaped_value)
else:
- self.cmd.extend(value)
+ self.cmd.extend(escaped_value)
else:
- self.cmd.extend([option, value])
+ # argparse gets confused if value(s) start with a dash.
+ # When an option expects a single value, the unambiguous way
+ # to specify it is with =
+ if isinstance(value, str):
+ self.cmd.extend(['%s=%s' % (option, value)])
+ else:
+ self.cmd.extend([option, value])
def check_extra_arg_type(self, arg, value):
value = getattr(value, 'held_object', value)