From 8402aa051a9d72095b7b5d85a73b2c423221d9f5 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 5 Aug 2014 13:04:34 +0200 Subject: [PATCH] conftypes: Use slicing instead of rstrip. "100%%".rstrip('%') would give use "100" instead of "100%" which is not what we want. --- qutebrowser/config/conftypes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qutebrowser/config/conftypes.py b/qutebrowser/config/conftypes.py index e3858d248..f6aaa217b 100644 --- a/qutebrowser/config/conftypes.py +++ b/qutebrowser/config/conftypes.py @@ -377,9 +377,9 @@ class Perc(BaseType): self.maxval = maxval def transform(self, value): - return int(value.rstrip('%')) if self.none_ok and not value: return + return int(value[:-1]) def validate(self, value): if not value: @@ -390,7 +390,7 @@ class Perc(BaseType): if not value.endswith('%'): raise ValidationError(value, "does not end with %") try: - intval = int(value.rstrip('%')) + intval = int(value[:-1]) except ValueError: raise ValidationError(value, "invalid percentage!") if self.minval is not None and intval < self.minval: @@ -472,7 +472,7 @@ class PercOrInt(BaseType): return if value.endswith('%'): try: - intval = int(value.rstrip('%')) + intval = int(value[:-1]) except ValueError: raise ValidationError(value, "invalid percentage!") if self.minperc is not None and intval < self.minperc: