From c46abd8f8985d851123a208f72a8cf18aec90db5 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 23 Jul 2015 14:08:34 +0200 Subject: [PATCH] Fix none_ok for RegexList and PercList. --- qutebrowser/config/configtypes.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index 3508b2ed0..badd41d2f 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -445,10 +445,17 @@ class PercList(List): self.maxval = maxval def transform(self, value): + if not value: + return None vals = super().transform(value) return [int(v[:-1]) if v is not None else None for v in vals] def validate(self, value): + if not value: + if self.none_ok: + return + else: + raise configexc.ValidationError(value, "may not be empty") vals = super().transform(value) perctype = Perc(minval=self.minval, maxval=self.maxval) try: @@ -786,11 +793,18 @@ class RegexList(List): self.flags = flags def transform(self, value): + if not value: + return None vals = super().transform(value) return [re.compile(v, self.flags) if v is not None else None for v in vals] def validate(self, value): + if not value: + if self.none_ok: + return + else: + raise configexc.ValidationError(value, "may not be empty!") try: vals = self.transform(value) except sre_constants.error as e: