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 1QS9yS-0003ew-QD for garchives@archives.gentoo.org; Thu, 02 Jun 2011 15:38:17 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1ABE71C050; Thu, 2 Jun 2011 15:38:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id E0AE31C050 for ; Thu, 2 Jun 2011 15:38:08 +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 2EB311B401A for ; Thu, 2 Jun 2011 15:38:08 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 8468180506 for ; Thu, 2 Jun 2011 15:38:07 +0000 (UTC) From: "Paweł Hajdan" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Paweł Hajdan" Message-ID: <5cd96f04deb82e55aa60f91a2340240c076771d8.phajdan.jr@gentoo> Subject: [gentoo-commits] proj/arch-tools:master commit in: / X-VCS-Repository: proj/arch-tools X-VCS-Files: bugzilla-viewer.py X-VCS-Directories: / X-VCS-Committer: phajdan.jr X-VCS-Committer-Name: Paweł Hajdan X-VCS-Revision: 5cd96f04deb82e55aa60f91a2340240c076771d8 Date: Thu, 2 Jun 2011 15:38:07 +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: 1f32cb424fbe3672d7b772abd275d698 commit: 5cd96f04deb82e55aa60f91a2340240c076771d8 Author: Pawel Hajdan, Jr gentoo org> AuthorDate: Thu Jun 2 15:37:54 2011 +0000 Commit: Pawe=C5=82 Hajdan gentoo org> CommitDate: Thu Jun 2 15:37:54 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/arch-tools.gi= t;a=3Dcommit;h=3D5cd96f04 Make sure to unicode-sanitize all strings passed to ncurses to prevent ru= ntime exceptions. --- bugzilla-viewer.py | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py index 686a3aa..e62ac98 100755 --- a/bugzilla-viewer.py +++ b/bugzilla-viewer.py @@ -17,6 +17,14 @@ import portage.versions =20 CPV_REGEX =3D re.compile("[A-Za-z0-9+_.-]+/[A-Za-z0-9+_-]+-[0-9]+(?:\.[0= -9]+)*[a-z0-9_]*(?:-r[0-9]+)?") =20 +def unicode_sanitize(text): + """Converts a possibly unicode text to a regular string.""" + if type(text) =3D=3D unicode: + real_output =3D text + else: + real_output =3D unicode(text, errors=3D'replace') + return real_output.encode("utf-8") + class TermTooSmall(Exception): pass =20 @@ -135,7 +143,7 @@ class MainWindow: =20 for i in range(len(self.bugs)): self.bugs_pad.addstr(i, 0, - " %d %s" % (self.bugs[i].id_number(), self.bugs[i].summary())) + unicode_sanitize(" %d %s" % (self.bugs[i].id_number(), self.bugs[= i].summary()))) =20 def scroll_bugs_pad(self, amount): height =3D len(self.bugs) @@ -218,11 +226,7 @@ class MainWindow: self.contents_pad_pos =3D 0 =20 for i in range(len(output)): - if type(output[i]) =3D=3D unicode: - real_output =3D output[i] - else: - real_output =3D unicode(output[i], errors=3D'replace') - self.contents_pad.addstr(i, 0, real_output.encode("utf-8")) + self.contents_pad.addstr(i, 0, unicode_sanitize(output[i])) =20 def scroll_contents_pad(self, amount): height =3D self.contents_pad_length - self.height + 5