From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 6795413855B for ; Sat, 19 Jan 2013 05:17:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 58DE0E04CB; Sat, 19 Jan 2013 05:17:01 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E7DCEE04CB for ; Sat, 19 Jan 2013 05:17:00 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E346633D8FF for ; Sat, 19 Jan 2013 05:16:59 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 69941E4073 for ; Sat, 19 Jan 2013 05:16:58 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1358572518.0d7e395a3227264ff8bcc2c35d024c2b39e07679.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/, pym/portage/ X-VCS-Repository: proj/portage X-VCS-Files: bin/glsa-check pym/portage/glsa.py X-VCS-Directories: bin/ pym/portage/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 0d7e395a3227264ff8bcc2c35d024c2b39e07679 X-VCS-Branch: master Date: Sat, 19 Jan 2013 05:16:58 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 0b0f6d5b-a318-4ad1-b055-9013a9262ea4 X-Archives-Hash: 8b34bb351823381d6684dbc4d1740194 commit: 0d7e395a3227264ff8bcc2c35d024c2b39e07679 Author: Andy Kittner gmx de> AuthorDate: Wed Jan 26 23:21:21 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat Jan 19 05:15:18 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0d7e395a Fix unicode vs. bytes issue in glsa-check (#341293) http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=01d40ffed91033119bae05dac5c9cea86b94aa2e --- bin/glsa-check | 17 ++++++++++------- pym/portage/glsa.py | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bin/glsa-check b/bin/glsa-check index 3d047b5..b2da90a 100755 --- a/bin/glsa-check +++ b/bin/glsa-check @@ -283,7 +283,7 @@ if mode == "test": # mail mode as requested by solar if mode == "mail": import portage.mail, socket - from io import StringIO + from io import BytesIO from email.mime.text import MIMEText # color doesn't make any sense for mail @@ -302,11 +302,13 @@ if mode == "mail": mysubject = "[glsa-check] Summary for %s" % socket.getfqdn() # need a file object for summarylist() - myfd = StringIO() - myfd.write("GLSA Summary report for host %s\n" % socket.getfqdn()) - myfd.write("(Command was: %s)\n\n" % " ".join(sys.argv)) + myfd = BytesIO() + line = "GLSA Summary report for host %s\n" % socket.getfqdn() + myfd.write(line.encode("utf-8")) + line = "(Command was: %s)\n\n" % " ".join(sys.argv) + myfd.write(line.encode("utf-8")) summarylist(glsalist, fd1=myfd, fd2=myfd) - summary = str(myfd.getvalue()) + summary = myfd.getvalue().decode("utf-8") myfd.close() myattachments = [] @@ -317,9 +319,10 @@ if mode == "mail": if verbose: sys.stderr.write(("invalid GLSA: %s (error message was: %s)\n" % (myid, e))) continue - myfd = StringIO() + myfd = BytesIO() myglsa.dump(outstream=myfd) - myattachments.append(MIMEText(str(myfd.getvalue()), _charset="utf8")) + attachment = myfd.getvalue().decode("utf-8") + myattachments.append(MIMEText(attachment, _charset="utf8")) myfd.close() mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, summary, myattachments) diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py index c0c69dd..1dd8a98 100644 --- a/pym/portage/glsa.py +++ b/pym/portage/glsa.py @@ -604,6 +604,7 @@ class Glsa: @param outfile: Stream that should be used for writing (defaults to sys.stdout) """ + outstream = getattr(outstream, "buffer", outstream) outstream = codecs.getwriter(encoding)(outstream) width = 76 outstream.write(("GLSA %s: \n%s" % (self.nr, self.title)).center(width)+"\n")