From c50cdf7e425425e957045f3b0ac5ba07e5351093 Mon Sep 17 00:00:00 2001 From: Michael Wiencek Date: Sun, 19 Jan 2014 22:50:35 -0600 Subject: [PATCH] Return the default Option value on TypeError Apparently Qt saves empty QStringLists as @Invalid, which sip converts to None in Python. Which throws a TypeError when fed back into list. --- picard/config.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/picard/config.py b/picard/config.py index 19da9be50..798d29cc6 100644 --- a/picard/config.py +++ b/picard/config.py @@ -41,14 +41,15 @@ class ConfigSection(LockableObject): def __getitem__(self, name): self.lock_for_read() key = "%s/%s" % (self.__name, name) + opt = Option.get(self.__name, name) + if opt is None: + return None try: - opt = Option.get(self.__name, name) if self.__config.contains(key): return opt.convert(self.__config.value(key)) return opt.default - except KeyError: - if self.__config.contains(key): - return self.__config.value(key) + except TypeError: + return opt.default finally: self.unlock() @@ -174,10 +175,7 @@ class Option(QtCore.QObject): @classmethod def get(cls, section, name): - try: - return cls.registry[(section, name)] - except KeyError: - raise KeyError("Option %s.%s not found." % (section, name)) + return cls.registry.get((section, name)) class PasswordOption(Option):