From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1PqLKU-0008JN-Gf for garchives@archives.gentoo.org; Fri, 18 Feb 2011 08:04:42 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A60D9E0799; Fri, 18 Feb 2011 08:04:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 75971E0799 for ; Fri, 18 Feb 2011 08:04:35 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E5BCB1B4078 for ; Fri, 18 Feb 2011 08:04:34 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 25D6E8006A for ; Fri, 18 Feb 2011 08:04:34 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/mail.py X-VCS-Directories: pym/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: e33e94307ba0bd2f3fff543c407eee812c4ea5c9 Date: Fri, 18 Feb 2011 08:04:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 72181010a5c38cceef2fdfd935d0252c commit: e33e94307ba0bd2f3fff543c407eee812c4ea5c9 Author: Zac Medico gentoo org> AuthorDate: Fri Feb 18 08:03:10 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Feb 18 08:03:10 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3De33e9430 mail: handle unicode in subject for python3 --- pym/portage/mail.py | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pym/portage/mail.py b/pym/portage/mail.py index f87efe2..598c1f9 100644 --- a/pym/portage/mail.py +++ b/pym/portage/mail.py @@ -67,9 +67,19 @@ def create_message(sender, recipient, subject, body, a= ttachments=3DNone): mymessage.set_unixfrom(sender) mymessage["To"] =3D recipient mymessage["From"] =3D sender - # Use Header as a workaround so that long subject lines are wrapped - # correctly by <=3Dpython-2.6 (gentoo bug #263370, python issue #1974). - mymessage["Subject"] =3D Header(subject) + + if sys.hexversion >=3D 0x3000000: + # Avoid UnicodeEncodeError in python3 with non-ascii characters. + # File "/usr/lib/python3.1/email/header.py", line 189, in __init__ + # self.append(s, charset, errors) + # File "/usr/lib/python3.1/email/header.py", line 262, in append + # input_bytes =3D s.encode(input_charset, errors) + #UnicodeEncodeError: 'ascii' codec can't encode characters in position= 0-9: ordinal not in range(128) + mymessage["Subject"] =3D subject + else: + # Use Header as a workaround so that long subject lines are wrapped + # correctly by <=3Dpython-2.6 (gentoo bug #263370, python issue #1974)= . + mymessage["Subject"] =3D Header(subject) mymessage["Date"] =3D time.strftime("%a, %d %b %Y %H:%M:%S %z") =09 return mymessage