1 |
Dnia 2014-06-21, o godz. 20:01:50 |
2 |
Mike Gilbert <floppym@g.o> napisał(a): |
3 |
|
4 |
> Index: python-utils-r1.eclass |
5 |
> =================================================================== |
6 |
> RCS file: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v |
7 |
> retrieving revision 1.58 |
8 |
> diff -u -r1.58 python-utils-r1.eclass |
9 |
> --- python-utils-r1.eclass 19 Jun 2014 15:10:55 -0000 1.58 |
10 |
> +++ python-utils-r1.eclass 21 Jun 2014 23:51:45 -0000 |
11 |
> @@ -1110,5 +1110,33 @@ |
12 |
> fi |
13 |
> } |
14 |
> |
15 |
> +# @FUNCTION: python_export_utf8_locale |
16 |
> +# @RETURN: 0 on success, 1 on failure. |
17 |
> +# @DESCRIPTION: |
18 |
> +# Attempts to export a usable UTF-8 locale in the LC_CTYPE variable. Does |
19 |
> +# nothing if LC_ALL is defined, or if the current locale uses a UTF-8 charmap. |
20 |
> +# This may be used to work around the quirky open() behavior of python3. |
21 |
> +python_export_utf8_locale() { |
22 |
> + debug-print-function ${FUNCNAME} "${@}" |
23 |
> + |
24 |
> + if [[ -z ${LC_ALL} && $(locale charmap) != UTF-8 ]]; then |
25 |
|
26 |
What about people with LC_ALL set? Should we complain? |
27 |
|
28 |
> + # Try English first, then everything else. |
29 |
> + local lang locales="en_US.UTF-8 $(locale -a)" |
30 |
|
31 |
I think we should start with C.UTF-8 :). |
32 |
|
33 |
> + |
34 |
> + for lang in ${locales}; do |
35 |
> + if [[ $(LC_CTYPE=${lang} locale charmap) == UTF-8 ]]; then |
36 |
|
37 |
This is a bit verbose when you try a locale that isn't supported. |
38 |
I suggest 2>/dev/null. |
39 |
|
40 |
> + export LC_CTYPE=${lang} |
41 |
> + return 0 |
42 |
> + fi |
43 |
> + done |
44 |
> + |
45 |
> + ewarn "Could not find a UTF-8 locale." |
46 |
|
47 |
I think you ought to be a little more verbose here. The user doesn't |
48 |
see anything else so he'll have no idea what's happening. |
49 |
|
50 |
> + return 1 |
51 |
> + fi |
52 |
> + |
53 |
> + return 0 |
54 |
> +} |
55 |
> + |
56 |
> + |
57 |
> _PYTHON_UTILS_R1=1 |
58 |
> fi |
59 |
> |
60 |
|
61 |
|
62 |
|
63 |
-- |
64 |
Best regards, |
65 |
Michał Górny |