Gentoo Archives: gentoo-dev

From: "Harald van Dijk" <truedfx@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Locale check in python_pkg_setup()
Date: Mon, 02 Aug 2010 21:39:44
Message-Id: 20100802214032.GA1584@boostbox
In Reply to: Re: [gentoo-dev] Locale check in python_pkg_setup() by Arfrever Frehtes Taifersar Arahesis
1 On Mon, Aug 02, 2010 at 11:02:20PM +0200, Arfrever Frehtes Taifersar Arahesis wrote:
2 > It would have to be parsed using e.g. grep and sed. It's easier to call Python in this case.
3
4 It's even easier not to.
5
6 > The call to Python is sufficiently fast:
7 >
8 > $ time python -c 'import os; print(os.environ.get("LC_ALL", os.environ.get("LC_CTYPE", os.environ.get("LANG", "POSIX"))))' > /dev/null
9 >
10 > real 0m0.062s
11 > user 0m0.051s
12 > sys 0m0.011s
13
14 Let's compare. On my system:
15
16 time python -c 'import os; print(os.environ.get("LC_ALL", os.environ.get("LC_CTYPE", os.environ.get("LANG", "POSIX"))))'
17 en_GB.UTF-8
18
19 real 0m0.020s
20 user 0m0.016s
21 sys 0m0.004s
22
23 time sh -c 'echo "${LC_ALL:-${LC_CTYPE:-${LANG:-POSIX}}}"'
24 en_GB.UTF-8
25
26 real 0m0.001s
27 user 0m0.000s
28 sys 0m0.000s
29
30 And that's after several runs for both, so it's not caused by the
31 initial load of python, which wasn't in memory yet.
32
33 Yes, 0.019s is very little, but in this case I see absolutely no benefit
34 whatsoever in calling python. Plus sh has the advantage of actually
35 working when LC_ALL is exported as "" (which in LC_* means the same as
36 having it unset)...
37
38 But why exactly are you concerned about LC_* being defined but not
39 exported anyway? You're checking from an ebuild; locales are going to
40 get inherited from portage or profile.env anyway, so you can just
41 assume that if they _are_ set, they're exported. The only way they might
42 not be is if the user is messing with the locale from the bashrc, and if
43 the user's doing that, the user really needs to fix the bashrc and
44 export the vars anyway.
45
46 None of this changes the fact that locale checks warns about bugs in packages,
47 not bugs in the user's configuration.