Gentoo Archives: gentoo-portage-dev

From: "Anthony G. Basile" <basile@××××××××××××××.edu>
To: gentoo-portage-dev@l.g.o
Cc: "Anthony G. Basile" <blueness@g.o>
Subject: [gentoo-portage-dev] [PATCH 1/3] pym/portage/util/locale.py: fix decoding for python2 with some locales
Date: Fri, 27 May 2016 14:26:59
Message-Id: 1464359204-21987-1-git-send-email-basile@opensource.dyc.edu
1 From: "Anthony G. Basile" <blueness@g.o>
2
3 When using python2 with some locales, like turkish, chr() is passed values not in
4 range(128) which cannot be decoded as ASCII, thus throwing a UnicodeDecodeError
5 exception. We use _unicode_decode() from portage.util to address this.
6
7 Signed-off-by: Anthony G. Basile <blueness@g.o>
8 ---
9 pym/portage/util/locale.py | 4 ++--
10 1 file changed, 2 insertions(+), 2 deletions(-)
11
12 diff --git a/pym/portage/util/locale.py b/pym/portage/util/locale.py
13 index 2a15ea1..093eb86 100644
14 --- a/pym/portage/util/locale.py
15 +++ b/pym/portage/util/locale.py
16 @@ -15,7 +15,7 @@ import textwrap
17 import traceback
18
19 import portage
20 -from portage.util import writemsg_level
21 +from portage.util import _unicode_decode, writemsg_level
22 from portage.util._ctypes import find_library, LoadLibrary
23
24
25 @@ -62,7 +62,7 @@ def _check_locale(silent):
26 "as LC_CTYPE in make.conf.")
27 msg = [l for l in textwrap.wrap(msg, 70)]
28 msg.append("")
29 - chars = lambda l: ''.join(chr(x) for x in l)
30 + chars = lambda l: ''.join(_unicode_decode(chr(x)) for x in l)
31 if uc != ruc:
32 msg.extend([
33 " %s -> %s" % (chars(lc), chars(ruc)),
34 --
35 2.7.3

Replies

Subject Author
[gentoo-portage-dev] [PATCH 3/3] pym/portage/util/locale.py: add a C module to help check locale "Anthony G. Basile" <basile@××××××××××××××.edu>
[gentoo-portage-dev] [PATCH 2/3] setup.py: add stub for building custom modules in C/C++ "Anthony G. Basile" <basile@××××××××××××××.edu>