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 937AB138CCC for ; Mon, 4 May 2015 06:25:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C1EC9E08AB; Mon, 4 May 2015 06:25:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4E085E08AA for ; Mon, 4 May 2015 06:25:07 +0000 (UTC) Received: from big_daddy.dol-sen.ca (S010634bdfa9ecf80.vc.shawcable.net [96.49.31.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dolsen) by smtp.gentoo.org (Postfix) with ESMTPSA id 4FB6734062A for ; Mon, 4 May 2015 06:25:06 +0000 (UTC) Date: Sun, 3 May 2015 23:25:03 -0700 From: Brian Dolbec To: gentoo-portage-dev@lists.gentoo.org Subject: Re: [gentoo-portage-dev] [PATCH] bintree.populate: binhost connection failure triggers TypeError (bug 532784) Message-ID: <20150503232503.54706511.dolsen@gentoo.org> In-Reply-To: <1430715153-27893-1-git-send-email-zmedico@gentoo.org> References: <1430715153-27893-1-git-send-email-zmedico@gentoo.org> Organization: Gentoo Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archives-Salt: e532c9ef-dae9-44dd-bb30-9f8f28a8572f X-Archives-Hash: 45a3537e60980ff84849d1fec6f944ca On Sun, 3 May 2015 21:52:33 -0700 Zac Medico wrote: > Since commit 4496ee37d6fa327ada635c67500e82f830141a9e, binhost > connection errors result in a TypeError. Fix it to call the unicode > function correctly (with only a single argument). Also, handle > a possible UnicodeDecodeError. > > Fixes: 4496ee37d6fa ("bintree.py: fix str() calls for Python 2 > (532784)") X-Gentoo-Bug: 532784 > X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=532784 > --- > pym/portage/dbapi/bintree.py | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/pym/portage/dbapi/bintree.py > b/pym/portage/dbapi/bintree.py index b37f388..4043016 100644 > --- a/pym/portage/dbapi/bintree.py > +++ b/pym/portage/dbapi/bintree.py > @@ -961,8 +961,12 @@ class binarytree(object): > # With Python 2, the > EnvironmentError message may # contain bytes or unicode, so use > _unicode to ensure # safety with all locales (bug #532784). > - writemsg("!!! %s\n\n" % _unicode(e, > - _encodings["stdio"], > errors="replace")) > + try: > + error_msg = _unicode(e) > + except UnicodeDecodeError as uerror: > + error_msg = > _unicode(uerror.object, > + encoding='utf_8', > errors='replace') > + writemsg("!!! %s\n\n" % error_msg) > del e > pkgindex = None > if proc is not None: Isn't this backwards from what was reported. It generated a UnicodeDecodeError when using additional args to unicode(). It needed to convert it to string so errors= needed to not be passed in. -- Brian Dolbec