On Tue, 16 Aug 2011 22:37:47 +0100, Patrick Totzke <patricktotzke@googlemail.com> wrote: > This prevents unsafe calls to decode for return > value None in get_authors/get_subject Thanks for the heads up, I just pushed a modified version of this. Some comments on the code below. Sebastian > - tag = Tags._get(self._tags).decode('utf-8') > + tag = Tags._get(self._tags) > + if tag: > + tag = tag.decode('UTF-8') This was already safe as if not nmlib.notmuch_tags_valid(self._tags): was making sure that something useful will be returned. > - return Thread._get_authors(self._thread).decode('UTF-8') > + authors = Thread._get_authors(self._thread) > + if authors: > + return authors.decode('UTF-8') > + return None > - return Thread._get_subject(self._thread).decode('UTF-8') > + subject = Thread._get_subject(self._thread) > + if subject: > + return subject.decode('UTF-8') > + return None Modified this to say: foo = get_foo() if foo is None: return None return foo.decode('UTF-8') Otherwise you would fall into a trap when e.g. the subject is empty and a '' is returned. Your code would have returned "None". My version will return ''. Thanks!