[PATCH] py3k: the basestring and unicode types are removed in python 3
authorJustus Winter <4winter@informatik.uni-hamburg.de>
Sun, 8 Jan 2012 14:06:29 +0000 (15:06 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:41:45 +0000 (09:41 -0800)
62/b0dc11019a33c69cbe22d1fb919ffa87a7eb6d [new file with mode: 0644]

diff --git a/62/b0dc11019a33c69cbe22d1fb919ffa87a7eb6d b/62/b0dc11019a33c69cbe22d1fb919ffa87a7eb6d
new file mode 100644 (file)
index 0000000..1326833
--- /dev/null
@@ -0,0 +1,126 @@
+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 A5F5441434B\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Jan 2012 06:06:54 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.001\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.001 tagged_above=-999 required=5\r
+       tests=[UNPARSEABLE_RELAY=0.001] 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 XCMf3xwDtIIl for <notmuch@notmuchmail.org>;\r
+       Sun,  8 Jan 2012 06:06:51 -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 2F35A414343\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Jan 2012 06:06:51 -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 A3768513C80\r
+       for <notmuch@notmuchmail.org>; Sun,  8 Jan 2012 15:06:49 +0100 (CET)\r
+Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
+       id EA9DADF2A2; Sun,  8 Jan 2012 15:06:48 +0100 (CET)\r
+Received: from thinkbox.jade-hamburg.de (unknown\r
+       [IPv6:fe80::216:d3ff:fe3e:5058%br0])\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 7A5BBDF2A0;\r
+       Sun,  8 Jan 2012 15:06:47 +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 1RjtOY-0007wh-Ty; Sun, 08 Jan 2012 15:06:47 +0100\r
+From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] py3k: the basestring and unicode types are removed in python\r
+ 3\r
+Date: Sun,  8 Jan 2012 15:06:29 +0100\r
+Message-Id:\r
+ <1326031589-30506-1-git-send-email-4winter@informatik.uni-hamburg.de>\r
+X-Mailer: git-send-email 1.7.7.3\r
+In-Reply-To: <20120108140444.26863.68188@thinkbox.jade-hamburg.de>\r
+References: <20120108140444.26863.68188@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: Sun, 08 Jan 2012 14:06:54 -0000\r
+\r
+---\r
+ bindings/python/notmuch/globals.py |   34 ++++++++++++++++++++++------------\r
+ 1 files changed, 22 insertions(+), 12 deletions(-)\r
+\r
+diff --git a/bindings/python/notmuch/globals.py b/bindings/python/notmuch/globals.py\r
+index 32ed9ae..4138460 100644\r
+--- a/bindings/python/notmuch/globals.py\r
++++ b/bindings/python/notmuch/globals.py\r
+@@ -31,12 +31,34 @@ if sys.version_info[0] == 2:\r
+     class Python3StringMixIn(object):\r
+         def __str__(self):\r
+             return unicode(self).encode('utf-8')\r
++\r
++\r
++    def _str(value):\r
++        """Ensure a nicely utf-8 encoded string to pass to libnotmuch\r
++\r
++        C++ code expects strings to be well formatted and\r
++        unicode strings to have no null bytes."""\r
++        if not isinstance(value, basestring):\r
++            raise TypeError("Expected str or unicode, got %s" % type(value))\r
++        if isinstance(value, unicode):\r
++            return value.encode('UTF-8')\r
++        return value\r
+ else:\r
+     class Python3StringMixIn(object):\r
+         def __str__(self):\r
+             return self.__unicode__()\r
\r
\r
++    def _str(value):\r
++        """Ensure a nicely utf-8 encoded string to pass to libnotmuch\r
++\r
++        C++ code expects strings to be well formatted and\r
++        unicode strings to have no null bytes."""\r
++        if not isinstance(value, str):\r
++            raise TypeError("Expected str, got %s" % type(value))\r
++        return value.encode('UTF-8')\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
+@@ -202,18 +224,6 @@ class NotInitializedError(NotmuchError):\r
+     status = STATUS.NOT_INITIALIZED\r
\r
\r
+-def _str(value):\r
+-    """Ensure a nicely utf-8 encoded string to pass to libnotmuch\r
+-\r
+-    C++ code expects strings to be well formatted and\r
+-    unicode strings to have no null bytes."""\r
+-    if not isinstance(value, basestring):\r
+-        raise TypeError("Expected str or unicode, got %s" % str(type(value)))\r
+-    if isinstance(value, unicode):\r
+-        return value.encode('UTF-8')\r
+-    return value\r
+-\r
+-\r
+ class NotmuchDatabaseS(Structure):\r
+     pass\r
+ NotmuchDatabaseP = POINTER(NotmuchDatabaseS)\r
+-- \r
+1.7.7.3\r
+\r