aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2020-02-02 18:38:48 +0100
committerGuido Günther <agx@sigxcpu.org>2020-02-02 18:39:31 +0100
commitf8883ebcd9ab958fb763329bb3b62f33fba017e1 (patch)
treeeef1d5e7eb68bf228d47e39188bbf07211b056d6
parentb80027c3eae4b553601cd2eaab587c349755fb90 (diff)
config: Be less picky about comments after boolean values
This makes 'patch-numbers = False # comment' work. Thanks: Mechtilde Stehmann for the report
-rw-r--r--gbp/config.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/gbp/config.py b/gbp/config.py
index 495ec63..1ca8def 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -620,12 +620,17 @@ class GbpOptionParser(OptionParser):
except KeyError:
default = self.config[neg]
+ default = default.strip()
+ parts = default.split(" ", 2)
+ if len(parts) > 1 and parts[1] == '#':
+ default = parts[0]
+
if default.lower() in ["true", "1"]:
val = 'True'
elif default.lower() in ["false", "0"]:
val = 'False'
else:
- raise ValueError("Boolean options must be True or False")
+ raise ValueError("Boolean options must be True or False, not '%s'" % default)
return eval(val)
def get_default(self, option_name, **kwargs):