1 |
Now that Patrick has his build system up and running again, we are seeing |
2 |
these UnicodeDecodeError bugs pop up again. Instead of playing whack-a-mole, |
3 |
let's set up a more reasonable default environment for running python3. |
4 |
|
5 |
Index: distutils-r1.eclass |
6 |
=================================================================== |
7 |
RCS file: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v |
8 |
retrieving revision 1.98 |
9 |
diff -u -r1.98 distutils-r1.eclass |
10 |
--- distutils-r1.eclass 21 Jun 2014 08:14:18 -0000 1.98 |
11 |
+++ distutils-r1.eclass 21 Jun 2014 23:51:44 -0000 |
12 |
@@ -684,6 +684,8 @@ |
13 |
} |
14 |
|
15 |
distutils-r1_src_configure() { |
16 |
+ python_export_utf8_locale |
17 |
+ |
18 |
if declare -f python_configure >/dev/null; then |
19 |
_distutils-r1_run_foreach_impl python_configure |
20 |
fi |
21 |
Index: python-utils-r1.eclass |
22 |
=================================================================== |
23 |
RCS file: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v |
24 |
retrieving revision 1.58 |
25 |
diff -u -r1.58 python-utils-r1.eclass |
26 |
--- python-utils-r1.eclass 19 Jun 2014 15:10:55 -0000 1.58 |
27 |
+++ python-utils-r1.eclass 21 Jun 2014 23:51:45 -0000 |
28 |
@@ -1110,5 +1110,33 @@ |
29 |
fi |
30 |
} |
31 |
|
32 |
+# @FUNCTION: python_export_utf8_locale |
33 |
+# @RETURN: 0 on success, 1 on failure. |
34 |
+# @DESCRIPTION: |
35 |
+# Attempts to export a usable UTF-8 locale in the LC_CTYPE variable. Does |
36 |
+# nothing if LC_ALL is defined, or if the current locale uses a UTF-8 charmap. |
37 |
+# This may be used to work around the quirky open() behavior of python3. |
38 |
+python_export_utf8_locale() { |
39 |
+ debug-print-function ${FUNCNAME} "${@}" |
40 |
+ |
41 |
+ if [[ -z ${LC_ALL} && $(locale charmap) != UTF-8 ]]; then |
42 |
+ # Try English first, then everything else. |
43 |
+ local lang locales="en_US.UTF-8 $(locale -a)" |
44 |
+ |
45 |
+ for lang in ${locales}; do |
46 |
+ if [[ $(LC_CTYPE=${lang} locale charmap) == UTF-8 ]]; then |
47 |
+ export LC_CTYPE=${lang} |
48 |
+ return 0 |
49 |
+ fi |
50 |
+ done |
51 |
+ |
52 |
+ ewarn "Could not find a UTF-8 locale." |
53 |
+ return 1 |
54 |
+ fi |
55 |
+ |
56 |
+ return 0 |
57 |
+} |
58 |
+ |
59 |
+ |
60 |
_PYTHON_UTILS_R1=1 |
61 |
fi |