[notmuch] Unicode in Python bindings
authorAmadeusz Żołnowski <aidecoe@aidecoe.name>
Sun, 7 Jul 2013 07:00:16 +0000 (09:00 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:55:54 +0000 (09:55 -0800)
16/f851c20302a3e40812bcd86a5eca2d88652798 [new file with mode: 0644]

diff --git a/16/f851c20302a3e40812bcd86a5eca2d88652798 b/16/f851c20302a3e40812bcd86a5eca2d88652798
new file mode 100644 (file)
index 0000000..11ae55d
--- /dev/null
@@ -0,0 +1,171 @@
+Return-Path: <nobody@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 12681431FAF\r
+       for <notmuch@notmuchmail.org>; Tue,  9 Jul 2013 02:49:47 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.002\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.002 tagged_above=-999 required=5\r
+       tests=[TVD_RCVD_SPACE_BRACKET=0.001, UNPARSEABLE_RELAY=0.001]\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 IISlbJzESpJX for <notmuch@notmuchmail.org>;\r
+       Tue,  9 Jul 2013 02:49:39 -0700 (PDT)\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 B2B4C431FAE\r
+       for <notmuch@notmuchmail.org>; Tue,  9 Jul 2013 02:49:38 -0700 (PDT)\r
+Received: from mail.jade-hamburg.de (mail.jade-hamburg.de [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 6D5456A4A0C\r
+       for <notmuch@notmuchmail.org>; Tue,  9 Jul 2013 11:49:32 +0200 (CEST)\r
+Received: by mail.jade-hamburg.de (Postfix, from userid 401)\r
+       id B8578DF2A2; Tue,  9 Jul 2013 11:49:31 +0200 (CEST)\r
+Received: from thinkbox.jade-hamburg.de (cryptobitch.de [88.198.7.68])\r
+       (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+       (No client certificate requested) (Authenticated sender: teythoon)\r
+       by mail.jade-hamburg.de (Postfix) with ESMTPSA id 6C537DF28B\r
+       for <notmuch@notmuchmail.org>; Tue,  9 Jul 2013 11:49:27 +0200 (CEST)\r
+Received: from teythoon by thinkbox.jade-hamburg.de with local (Exim 4.80)\r
+       (envelope-from <nobody@thinkbox.jade-hamburg.de>) id 1UwUY2-0001Qr-71\r
+       for notmuch@notmuchmail.org; Tue, 09 Jul 2013 11:49:26 +0200\r
+Resent-Date: Tue, 09 Jul 2013 11:49:26 +0200\r
+Resent-Message-Id: <E1UwUY2-0001Qr-71@thinkbox.jade-hamburg.de>\r
+Received: from mailhost.informatik.uni-hamburg.de [134.100.9.70]\r
+       by jadE.jadE-Hamburg.de with IMAP (fetchmail-6.3.9-rc2)\r
+       for <teythoon@localhost> (single-drop);\r
+       Sun, 07 Jul 2013 09:01:19 +0200 (CEST)\r
+Received: from mailhost.informatik.uni-hamburg.de ([unix socket])\r
+       by mailhost (Cyrus v2.3.16) with LMTPA;\r
+       Sun, 07 Jul 2013 09:00:24 +0200\r
+X-Sieve: CMU Sieve 2.3\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by mailhost.informatik.uni-hamburg.de (Postfix) with ESMTP id 085F02BC\r
+       for <4winter@informatik.uni-hamburg.de>;\r
+       Sun,  7 Jul 2013 09:00:24 +0200 (CEST)\r
+X-Virus-Scanned: amavisd-new at informatik.uni-hamburg.de\r
+Received: from mailhost.informatik.uni-hamburg.de ([127.0.0.1])\r
+       by localhost (mailhost.informatik.uni-hamburg.de [127.0.0.1])\r
+       (amavisd-new, port 10024)\r
+       with LMTP id 4QEaQhRmctP4 for <4winter@informatik.uni-hamburg.de>;\r
+       Sun,  7 Jul 2013 09:00:20 +0200 (CEST)\r
+X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5\r
+       BL_NJABL=SKIP(-1.5) CL_IP_EQ_HELO_IP=-2 (check from: .aidecoe. - helo:\r
+       .mail-bk0-f41.google. - helo-domain: .google.)\r
+       FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -8.5\r
+Received: from mail-bk0-f41.google.com (mail-bk0-f41.google.com\r
+       [209.85.214.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (Client CN "smtp.gmail.com",\r
+       Issuer "Google Internet Authority" (verified OK))\r
+       by mailhost.informatik.uni-hamburg.de (Postfix) with ESMTPS id 54E692BB\r
+       for <4winter@informatik.uni-hamburg.de>;\r
+       Sun,  7 Jul 2013 09:00:19 +0200 (CEST)\r
+Received: by mail-bk0-f41.google.com with SMTP id jc3so1465854bkc.14\r
+       for <4winter@informatik.uni-hamburg.de>;\r
+       Sun, 07 Jul 2013 00:00:19 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=from:to:subject:user-agent:date:message-id:mime-version\r
+       :content-type:x-gm-message-state;\r
+       bh=iV83mH3O1R0iAxhhbmEE6gBIGmdWraTzccthWZKWoy8=;\r
+       b=YNTPVhysrfqll3pNjX14dQpeAsy6UcUCgd8FvSz09/S9XEaYyYg5yeHz2wrvDZlBlX\r
+       1bBwV+GY3ibYNYfUyo6JqrhtJ+sERLnW1XYudk3Fk6u96XzFzuttZpKCtWKbvltjfVph\r
+       TM41v814YdxlN7A+sk3DQ7jUf7+On0EzDty5sulB+b0Xt1U/zPePrYCJoQYsDhwrIXlQ\r
+       yn4tgvG88bU+PWXI5pWmeQE3SalkUZn/y9rkULyiFPMJDMTKxpZFdkwB+DzgXofkp21j\r
+       lWaP6S27oXo2vmXDph7WDtSb7X2yKfFkwtNvSCRtj/BnPr4zYZuVGvtd4TLW/2CWs8+e\r
+       1Wig==\r
+X-Received: by 10.205.130.67 with SMTP id hl3mr2583382bkc.61.1373180419276;\r
+       Sun, 07 Jul 2013 00:00:19 -0700 (PDT)\r
+From: Amadeusz =?utf-8?B?xbtvxYJub3dza2k=?= <aidecoe@aidecoe.name>\r
+To: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+Subject: [notmuch] Unicode in Python bindings\r
+User-Agent: Notmuch/0.15.2 (http://notmuchmail.org) Emacs/24.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Sun, 07 Jul 2013 09:00:16 +0200\r
+Message-ID: <87txk6zwfz.fsf@raeviah.aidecoe.name>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; boundary="=-=-=";\r
+       micalg=pgp-sha1; protocol="application/pgp-signature"\r
+X-Gm-Message-State:\r
+ ALoCoQl9lHlNXHB3cdksAJhxQ8jpPMCVt2kXej1sNqQ7ciTTAWy6VBuT8bk7E3ijw0KPgILxZGk/\r
+X-Alot-OpenPGP-Signature-Valid: True\r
+X-Alot-OpenPGP-Signature-Message: Valid: F0134531E1DBFAB5\r
+Resent-From: Justus Winter <4winter@informatik.uni-hamburg.de>\r
+Resent-To: notmuch mailing list <notmuch@notmuchmail.org>\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: Tue, 09 Jul 2013 09:49:47 -0000\r
+\r
+--=-=-=\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+Hello,\r
+\r
+I have come across a problem with Unicode [1] in afew mail filter which\r
+uses Notmuch Python bindings and it has eventually bringed us to\r
+confusion about Unicode handling in Python bindings.\r
+\r
+Shouldn't __unicode__() methods return value of type unicode?  Let's\r
+take an example of __unicode__() method from Message class:\r
+\r
+    def __unicode__(self):\r
+        format =3D "%s (%s) (%s)"\r
+        return format % (self.get_header('from'),\r
+                         self.get_tags(),=20=20=20=20=20=20=20=20=20=20=20=\r
+=20=20=20=20=20\r
+                         date.fromtimestamp(self.get_date()),\r
+                        )\r
+\r
+format is of type str, not unicode and method is eventually going to\r
+return str, while the user of the API is expecting unicode type.\r
+\r
+I haven't programmed in Python 3, yet - only in Python 2, so maybe I am\r
+missing something.  When I was writing a big project in Python 2, I have\r
+eventually decided to use u'' literals everywhere and decode any str to\r
+unicode ASAP - and this solved all issues wrt encodings.  I guess that\r
+mixing Python 2 and 3 gets even more problematic.\r
+\r
+Could you review (and fix if it is needed) Python bindings in context of\r
+unicode handling, please?\r
+\r
+\r
+[1] https://github.com/teythoon/afew/issues/36\r
+\r
+\r
+Regards,\r
+\r
+=2D-=20\r
+Amadeusz =C5=BBo=C5=82nowski\r
+\r
+--=-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v2.0.20 (GNU/Linux)\r
+\r
+iQEcBAEBAgAGBQJR2RIAAAoJEPATRTHh2/q1jeEH/2+RY69kyuKNz7gdBY5IvKrV\r
+f1WYHMeGkHFcWMC6Rm6dbaXrzfJe6IP7XW+3MaWNErbfsBQzRiUdI+DPPUQZOpI9\r
+KVFCx1wa4jtBrf++kUowV3GlKGyyoDr8W9Gii8wnAw7rRRX9Qv4CP0sNhxXLj5xR\r
+WcmjFLGvuEUXUVZZCAqKfpuXa+BA/ix1gPSfHEK3Gr8TkKbsFzR2GGZxpyq+znsq\r
+NrYBLcD2zAP9UUQ+WVKpo8+x9y++WnEkduWqDX2exvUhHl2u3Rl6co0Mg03/HtSQ\r
+1Bb7MbbATEDC1KD7GbxQ42XOEEzXjiIXeAjGQFmEVtTIOalSbZ5TFVJF1OGWlKU=\r
+=peoP\r
+-----END PGP SIGNATURE-----\r
+--=-=-=--\r