From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-portage-dev+bounces-5784-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id C8DA913828B
	for <garchives@archives.gentoo.org>; Fri, 27 May 2016 14:26:59 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 6A9CD141F9;
	Fri, 27 May 2016 14:26:57 +0000 (UTC)
Received: from virtual.dyc.edu (mail.virtual.dyc.edu [67.222.116.22])
	by pigeon.gentoo.org (Postfix) with ESMTP id EFCC81412D
	for <gentoo-portage-dev@lists.gentoo.org>; Fri, 27 May 2016 14:26:56 +0000 (UTC)
Received: from opensource.dyc.edu (unknown [67.222.116.23])
	by virtual.dyc.edu (Postfix) with ESMTP id 673647E0002;
	Fri, 27 May 2016 10:26:56 -0400 (EDT)
Received: by opensource.dyc.edu (Postfix, from userid 1001)
	id CB59F2B0010F; Fri, 27 May 2016 10:26:47 -0400 (EDT)
From: "Anthony G. Basile" <basile@opensource.dyc.edu>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Anthony G. Basile" <blueness@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH 1/3] pym/portage/util/locale.py: fix decoding for python2 with some locales
Date: Fri, 27 May 2016 10:26:42 -0400
Message-Id: <1464359204-21987-1-git-send-email-basile@opensource.dyc.edu>
X-Mailer: git-send-email 1.7.6.1
Precedence: bulk
List-Post: <mailto:gentoo-portage-dev@lists.gentoo.org>
List-Help: <mailto:gentoo-portage-dev+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-portage-dev+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-portage-dev+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-portage-dev.gentoo.org>
X-BeenThere: gentoo-portage-dev@lists.gentoo.org
Reply-to: gentoo-portage-dev@lists.gentoo.org
X-Archives-Salt: f06c6347-c5d5-4197-9013-68fa05d45e60
X-Archives-Hash: 144b34057049ecea2dc8df219d651aab

From: "Anthony G. Basile" <blueness@gentoo.org>

When using python2 with some locales, like turkish, chr() is passed values not in
range(128) which cannot be decoded as ASCII, thus throwing a UnicodeDecodeError
exception.  We use _unicode_decode() from portage.util to address this.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
---
 pym/portage/util/locale.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/util/locale.py b/pym/portage/util/locale.py
index 2a15ea1..093eb86 100644
--- a/pym/portage/util/locale.py
+++ b/pym/portage/util/locale.py
@@ -15,7 +15,7 @@ import textwrap
 import traceback
 
 import portage
-from portage.util import writemsg_level
+from portage.util import _unicode_decode, writemsg_level
 from portage.util._ctypes import find_library, LoadLibrary
 
 
@@ -62,7 +62,7 @@ def _check_locale(silent):
 			"as LC_CTYPE in make.conf.")
 		msg = [l for l in textwrap.wrap(msg, 70)]
 		msg.append("")
-		chars = lambda l: ''.join(chr(x) for x in l)
+		chars = lambda l: ''.join(_unicode_decode(chr(x)) for x in l)
 		if uc != ruc:
 			msg.extend([
 				"  %s -> %s" % (chars(lc), chars(ruc)),
-- 
2.7.3