Gentoo Archives: gentoo-python

From: Mike Gilbert <floppym@g.o>
To: "Michał Górny" <mgorny@g.o>
Cc: gentoo-python <gentoo-python@l.g.o>, Gentoo Python Project <python@g.o>
Subject: Re: [gentoo-python] [PATCH] Attempt to export a UTF-8 locale in distutils-r1
Date: Sun, 22 Jun 2014 14:18:46
Message-Id: CAJ0EP42F4TwcwiLzL5-xwc9cRKwk6FM++PAdp2iukk7jAckhPg@mail.gmail.com
In Reply to: Re: [gentoo-python] [PATCH] Attempt to export a UTF-8 locale in distutils-r1 by "Michał Górny"
1 On Sun, Jun 22, 2014 at 2:56 AM, Michał Górny <mgorny@g.o> wrote:
2 > Dnia 2014-06-21, o godz. 20:01:50
3 > Mike Gilbert <floppym@g.o> napisał(a):
4 >
5 >> Index: python-utils-r1.eclass
6 >> ===================================================================
7 >> RCS file: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v
8 >> retrieving revision 1.58
9 >> diff -u -r1.58 python-utils-r1.eclass
10 >> --- python-utils-r1.eclass 19 Jun 2014 15:10:55 -0000 1.58
11 >> +++ python-utils-r1.eclass 21 Jun 2014 23:51:45 -0000
12 >> @@ -1110,5 +1110,33 @@
13 >> fi
14 >> }
15 >>
16 >> +# @FUNCTION: python_export_utf8_locale
17 >> +# @RETURN: 0 on success, 1 on failure.
18 >> +# @DESCRIPTION:
19 >> +# Attempts to export a usable UTF-8 locale in the LC_CTYPE variable. Does
20 >> +# nothing if LC_ALL is defined, or if the current locale uses a UTF-8 charmap.
21 >> +# This may be used to work around the quirky open() behavior of python3.
22 >> +python_export_utf8_locale() {
23 >> + debug-print-function ${FUNCNAME} "${@}"
24 >> +
25 >> + if [[ -z ${LC_ALL} && $(locale charmap) != UTF-8 ]]; then
26 >
27 > What about people with LC_ALL set? Should we complain?
28 >
29
30 Yeah, I guess that makes sense. I just wanted to avoid overriding it
31 and causing people to get messages in another language, etc.
32
33 >> + # Try English first, then everything else.
34 >> + local lang locales="en_US.UTF-8 $(locale -a)"
35 >
36 > I think we should start with C.UTF-8 :).
37 >
38
39 I agree. However, our glibc doesn't actually support that. ^_^
40
41 >> +
42 >> + for lang in ${locales}; do
43 >> + if [[ $(LC_CTYPE=${lang} locale charmap) == UTF-8 ]]; then
44 >
45 > This is a bit verbose when you try a locale that isn't supported.
46 > I suggest 2>/dev/null.
47 >
48
49 Will do.
50
51 >> + export LC_CTYPE=${lang}
52 >> + return 0
53 >> + fi
54 >> + done
55 >> +
56 >> + ewarn "Could not find a UTF-8 locale."
57 >
58 > I think you ought to be a little more verbose here. The user doesn't
59 > see anything else so he'll have no idea what's happening.
60 >
61
62 Will do.