From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 89529429E25 for ; Fri, 12 Aug 2011 06:23:37 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d33nzs1lezMe for ; Fri, 12 Aug 2011 06:23:37 -0700 (PDT) Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id D42E5431FB6 for ; Fri, 12 Aug 2011 06:23:36 -0700 (PDT) Received: by wyg36 with SMTP id 36so2429200wyg.26 for ; Fri, 12 Aug 2011 06:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=x+tLK+BIH7R6DFAp4wzAe+gNJ5e1zJMDh2myoRQi/Ds=; b=ffjZm29es/hBKWtKGKkqeIQJZ4nm7OM4OvkhNyVN5GKrmHQIE5/3gZPlUQ2A5aWSit twOTAJcJ9qXOYgyco+feI/yWC+06JkQ/uhHEvbzUo/eafFtMwQx5hnnvrb3mbMW9wzw9 lHoPuxI3alUcTFXaiRyjD9whoJcOIDDwFy258= Received: by 10.216.131.134 with SMTP id m6mr283278wei.78.1313155413940; Fri, 12 Aug 2011 06:23:33 -0700 (PDT) Received: from localhost (dhcp-91-036.inf.ed.ac.uk [129.215.91.36]) by mx.google.com with ESMTPS id e7sm727170wed.33.2011.08.12.06.23.31 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 12 Aug 2011 06:23:32 -0700 (PDT) From: Patrick Totzke To: notmuch@notmuchmail.org Subject: [PATCH] [python] decode headers from utf-8 to unicode Date: Fri, 12 Aug 2011 14:23:28 +0100 Message-Id: <1313155408-17156-1-git-send-email-patricktotzke@gmail.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <87wrejnj1i.fsf@SSpaeth.de> References: <87wrejnj1i.fsf@SSpaeth.de> Cc: patrick X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Aug 2011 13:23:37 -0000 From: patrick as mail headers are stored as utf-8 in the index, it is safe to return them as unicode strings directly --- bindings/python/notmuch/message.py | 4 ++-- bindings/python/notmuch/thread.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py index 435a05d..ae6ae1b 100644 --- a/bindings/python/notmuch/message.py +++ b/bindings/python/notmuch/message.py @@ -395,7 +395,7 @@ class Message(object): header = Message._get_header(self._msg, header) if header == None: raise NotmuchError(STATUS.NULL_POINTER) - return header + return header.decode('UTF-8') def get_filename(self): """Returns the file path of the message file @@ -747,7 +747,7 @@ class Message(object): """A message() is represented by a 1-line summary""" msg = {} msg['from'] = self.get_header('from') - msg['tags'] = str(self.get_tags()) + msg['tags'] = self.get_tags() msg['date'] = date.fromtimestamp(self.get_date()) return "%(from)s (%(date)s) (%(tags)s)" % (msg) diff --git a/bindings/python/notmuch/thread.py b/bindings/python/notmuch/thread.py index 60f6c29..120f925 100644 --- a/bindings/python/notmuch/thread.py +++ b/bindings/python/notmuch/thread.py @@ -292,7 +292,7 @@ class Thread(object): """ if self._thread is None: raise NotmuchError(STATUS.NOT_INITIALIZED) - return Thread._get_authors(self._thread) + return Thread._get_authors(self._thread).decode('UTF-8') def get_subject(self): """Returns the Subject of 'thread' @@ -302,7 +302,7 @@ class Thread(object): """ if self._thread is None: raise NotmuchError(STATUS.NOT_INITIALIZED) - return Thread._get_subject(self._thread) + return Thread._get_subject(self._thread).decode('UTF-8') def get_newest_date(self): """Returns time_t of the newest message date -- 1.7.4.1