--- /dev/null
+Return-Path: <teythoon@jade-hamburg.de>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id EB0D3429E2F\r
+ for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 05:04:50 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id L4+mpuVvnR5N for <notmuch@notmuchmail.org>;\r
+ Wed, 14 Dec 2011 05:04:50 -0800 (PST)\r
+Received: from mail.cryptobitch.de (cryptobitch.de [88.198.7.68])\r
+ (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id BEC39429E27\r
+ for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 05:04:49 -0800 (PST)\r
+Received: from mail.jade-hamburg.de (unknown [85.183.11.228])\r
+ (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by mail.cryptobitch.de (Postfix) with ESMTPSA id 8936950F522\r
+ for <notmuch@notmuchmail.org>; Wed, 14 Dec 2011 14:04:48 +0100 (CET)\r
+Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
+ id 7CCBADF2A1; Wed, 14 Dec 2011 14:04:47 +0100 (CET)\r
+Received: from thinkbox.jade-hamburg.de (unknown [85.183.11.228])\r
+ (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
+ (No client certificate requested) (Authenticated sender: teythoon)\r
+ by mail.jade-hamburg.de (Postfix) with ESMTPSA id E77F4DF29F;\r
+ Wed, 14 Dec 2011 14:04:43 +0100 (CET)\r
+Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.77)\r
+ (envelope-from <teythoon@thinkbox.jade-hamburg.de>)\r
+ id 1RaoVm-00086t-N6; Wed, 14 Dec 2011 14:04:42 +0100\r
+From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 6/7] py3k: Add and use a mixin class that implements __str__\r
+Date: Wed, 14 Dec 2011 14:04:35 +0100\r
+Message-Id:\r
+ <1323867875-30684-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+X-Mailer: git-send-email 1.7.7.3\r
+In-Reply-To: <E1RaoOA-0007ka-G7@thinkbox.jade-hamburg.de>\r
+References: <E1RaoOA-0007ka-G7@thinkbox.jade-hamburg.de>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 14 Dec 2011 13:04:51 -0000\r
+\r
+---\r
+ bindings/python/notmuch/filename.py | 7 ++-----\r
+ bindings/python/notmuch/globals.py | 15 +++++++++++----\r
+ bindings/python/notmuch/message.py | 8 +++-----\r
+ bindings/python/notmuch/tag.py | 7 ++-----\r
+ bindings/python/notmuch/thread.py | 7 ++-----\r
+ 5 files changed, 20 insertions(+), 24 deletions(-)\r
+\r
+diff --git a/bindings/python/notmuch/filename.py b/bindings/python/notmuch/filename.py\r
+index a7cd7e6..969931a 100644\r
+--- a/bindings/python/notmuch/filename.py\r
++++ b/bindings/python/notmuch/filename.py\r
+@@ -18,10 +18,10 @@ Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>'\r
+ """\r
+ from ctypes import c_char_p\r
+ from notmuch.globals import (nmlib, STATUS, NotmuchError,\r
+- NotmuchFilenamesP, NotmuchMessageP)\r
++ NotmuchFilenamesP, NotmuchMessageP, _str, Python3StringMixIn)\r
+ \r
+ \r
+-class Filenames(object):\r
++class Filenames(Python3StringMixIn):\r
+ """Represents a list of filenames as returned by notmuch\r
+ \r
+ This object contains the Filenames iterator. The main function is\r
+@@ -98,9 +98,6 @@ class Filenames(object):\r
+ \r
+ self._files = None\r
+ \r
+- def __str__(self):\r
+- return unicode(self).encode('utf-8')\r
+-\r
+ def __unicode__(self):\r
+ """Represent Filenames() as newline-separated list of full paths\r
+ \r
+diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py\r
+index c52790c..2111b86 100644\r
+--- a/bindings/python/notmuch/globals.py\r
++++ b/bindings/python/notmuch/globals.py\r
+@@ -28,6 +28,16 @@ except:\r
+ raise ImportError("Could not find shared 'notmuch' library.")\r
+ \r
+ \r
++if sys.version_info[0] == 2:\r
++ class Python3StringMixIn(object):\r
++ def __str__(self):\r
++ return unicode(self).encode('utf-8')\r
++else:\r
++ class Python3StringMixIn(object):\r
++ def __str__(self):\r
++ return self.__unicode__()\r
++\r
++\r
+ class Enum(object):\r
+ """Provides ENUMS as "code=Enum(['a','b','c'])" where code.a=0 etc..."""\r
+ def __init__(self, names):\r
+@@ -90,7 +100,7 @@ argument to receive a human readable string"""\r
+ STATUS.__name__ = 'STATUS'\r
+ \r
+ \r
+-class NotmuchError(Exception):\r
++class NotmuchError(Exception, Python3StringMixIn):\r
+ """Is initiated with a (notmuch.STATUS[, message=None]). It will not\r
+ return an instance of the class NotmuchError, but a derived instance\r
+ of a more specific Error Message, e.g. OutOfMemoryError. Each status\r
+@@ -134,9 +144,6 @@ class NotmuchError(Exception):\r
+ self.status = status\r
+ self.message = message\r
+ \r
+- def __str__(self):\r
+- return unicode(self).encode('utf-8')\r
+-\r
+ def __unicode__(self):\r
+ if self.message is not None:\r
+ return self.message\r
+diff --git a/bindings/python/notmuch/message.py b/bindings/python/notmuch/message.py\r
+index bf0c4da..955382d 100644\r
+--- a/bindings/python/notmuch/message.py\r
++++ b/bindings/python/notmuch/message.py\r
+@@ -21,7 +21,8 @@ Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>'\r
+ \r
+ from ctypes import c_char_p, c_long, c_uint, c_int\r
+ from datetime import date\r
+-from notmuch.globals import (nmlib, STATUS, NotmuchError, Enum, _str,\r
++from notmuch.globals import (\r
++ nmlib, STATUS, NotmuchError, Enum, _str, Python3StringMixIn,\r
+ NotmuchTagsP, NotmuchMessagesP, NotmuchMessageP, NotmuchFilenamesP)\r
+ from notmuch.tag import Tags\r
+ from notmuch.filename import Filenames\r
+@@ -239,7 +240,7 @@ class Messages(object):\r
+ sys.stdout.write(set_end)\r
+ \r
+ \r
+-class Message(object):\r
++class Message(Python3StringMixIn):\r
+ """Represents a single Email message\r
+ \r
+ Technically, this wraps the underlying *notmuch_message_t*\r
+@@ -796,9 +797,6 @@ class Message(object):\r
+ """Represent a Message() object by str()"""\r
+ return self.__str__()\r
+ \r
+- def __str__(self):\r
+- return unicode(self).encode('utf-8')\r
+-\r
+ def __unicode__(self):\r
+ format = "%s (%s) (%s)"\r
+ return format % (self.get_header('from'),\r
+diff --git a/bindings/python/notmuch/tag.py b/bindings/python/notmuch/tag.py\r
+index d42ba77..ceb7244 100644\r
+--- a/bindings/python/notmuch/tag.py\r
++++ b/bindings/python/notmuch/tag.py\r
+@@ -17,10 +17,10 @@ along with notmuch. If not, see <http://www.gnu.org/licenses/>.\r
+ Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>'\r
+ """\r
+ from ctypes import c_char_p\r
+-from notmuch.globals import nmlib, STATUS, NotmuchError, NotmuchTagsP\r
++from notmuch.globals import nmlib, STATUS, NotmuchError, NotmuchTagsP, _str, Python3StringMixIn\r
+ \r
+ \r
+-class Tags(object):\r
++class Tags(Python3StringMixIn):\r
+ """Represents a list of notmuch tags\r
+ \r
+ This object provides an iterator over a list of notmuch tags (which\r
+@@ -111,9 +111,6 @@ class Tags(object):\r
+ left."""\r
+ return self._valid(self._tags) > 0\r
+ \r
+- def __str__(self):\r
+- return unicode(self).encode('utf-8')\r
+-\r
+ def __unicode__(self):\r
+ """string representation of :class:`Tags`: a space separated list of tags\r
+ \r
+diff --git a/bindings/python/notmuch/thread.py b/bindings/python/notmuch/thread.py\r
+index 39285d6..7393097 100644\r
+--- a/bindings/python/notmuch/thread.py\r
++++ b/bindings/python/notmuch/thread.py\r
+@@ -20,13 +20,13 @@ Copyright 2010 Sebastian Spaeth <Sebastian@SSpaeth.de>'\r
+ from ctypes import c_char_p, c_long, c_int\r
+ from notmuch.globals import (nmlib, STATUS,\r
+ NotmuchError, NotmuchThreadP, NotmuchThreadsP, NotmuchMessagesP,\r
+- NotmuchTagsP,)\r
++ NotmuchTagsP, Python3StringMixIn)\r
+ from notmuch.message import Messages\r
+ from notmuch.tag import Tags\r
+ from datetime import date\r
+ \r
+ \r
+-class Threads(object):\r
++class Threads(Python3StringMixIn):\r
+ """Represents a list of notmuch threads\r
+ \r
+ This object provides an iterator over a list of notmuch threads\r
+@@ -392,9 +392,6 @@ class Thread(object):\r
+ raise NotmuchError(STATUS.NULL_POINTER)\r
+ return Tags(tags_p, self)\r
+ \r
+- def __str__(self):\r
+- return unicode(self).encode('utf-8')\r
+-\r
+ def __unicode__(self):\r
+ frm = "thread:%s %12s [%d/%d] %s; %s (%s)"\r
+ \r
+-- \r
+1.7.7.3\r
+\r