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 571EA138CAE for ; Mon, 4 May 2015 04:53:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 23BD4E0896; Mon, 4 May 2015 04:52:56 +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 92498E0884 for ; Mon, 4 May 2015 04:52:55 +0000 (UTC) Received: from localhost.localdomain (ip174-67-205-96.oc.oc.cox.net [174.67.205.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zmedico) by smtp.gentoo.org (Postfix) with ESMTPSA id 31E44340A9B; Mon, 4 May 2015 04:52:54 +0000 (UTC) From: Zac Medico To: gentoo-portage-dev@lists.gentoo.org Cc: Zac Medico Subject: [gentoo-portage-dev] [PATCH] bintree.populate: binhost connection failure triggers TypeError (bug 532784) Date: Sun, 3 May 2015 21:52:33 -0700 Message-Id: <1430715153-27893-1-git-send-email-zmedico@gentoo.org> X-Mailer: git-send-email 2.3.5 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 X-Archives-Salt: e42b489f-9b6b-4a86-b038-a3548f574989 X-Archives-Hash: 461cafb3eab6cccff3e91cd23e942268 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: -- 2.3.5