From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1OfI4S-00086i-9L for garchives@archives.gentoo.org; Sat, 31 Jul 2010 19:50:12 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A28B5E09FE; Sat, 31 Jul 2010 19:50:09 +0000 (UTC) Received: from mail-iw0-f181.google.com (mail-iw0-f181.google.com [209.85.214.181]) by pigeon.gentoo.org (Postfix) with ESMTP id 059ECE09CC for ; Sat, 31 Jul 2010 19:49:50 +0000 (UTC) Received: by iwn42 with SMTP id 42so2757329iwn.40 for ; Sat, 31 Jul 2010 12:49:50 -0700 (PDT) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Received: by 10.231.31.197 with SMTP id z5mr4050914ibc.80.1280605790581; Sat, 31 Jul 2010 12:49:50 -0700 (PDT) Sender: antarus@scriptkitty.com Received: by 10.231.148.2 with HTTP; Sat, 31 Jul 2010 12:49:50 -0700 (PDT) In-Reply-To: <201007311645.49028.Arfrever@gentoo.org> References: <201007300116.43653.Arfrever@gentoo.org> <20100730023622.GB15031@hrair> <201007311645.49028.Arfrever@gentoo.org> Date: Sat, 31 Jul 2010 12:49:50 -0700 X-Google-Sender-Auth: fCNVJ_ixWk0dines-53ZQLGbYdE Message-ID: Subject: Re: [gentoo-dev] Locale check in python_pkg_setup() From: Alec Warner To: gentoo-dev@lists.gentoo.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Archives-Salt: f41c75e5-679a-4e23-8152-6398e2a34c7d X-Archives-Hash: 5d89efe0fd26b9b6b5e0a2a5cff39b5f On Sat, Jul 31, 2010 at 7:44 AM, Arfrever Frehtes Taifersar Arahesis wrote: > 2010-07-30 04:36:22 Brian Harring napisa=C5=82(a): >> On Fri, Jul 30, 2010 at 01:16:42AM +0200, Arfrever Frehtes Taifersar Ara= hesis wrote: >> > --- python.eclass >> > +++ python.eclass >> > @@ -355,6 +355,8 @@ >> > =C2=A0 =C2=A0 # Check if phase is pkg_setup(). >> > =C2=A0 =C2=A0 [[ "${EBUILD_PHASE}" !=3D "setup" ]] && die "${FUNCNAME}= () can be used only in pkg_setup() phase" >> > >> > + =C2=A0 local locale >> > + >> > =C2=A0 =C2=A0 if [[ "$#" -ne 0 ]]; then >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 die "${FUNCNAME}() does not = accept arguments" >> > =C2=A0 =C2=A0 fi >> > @@ -407,6 +409,16 @@ >> > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 unset -f python_pkg_setup_ch= eck_USE_flags >> > =C2=A0 =C2=A0 fi >> > >> > + =C2=A0 locale=3D"$(python -c 'import os; print(os.environ.get("LC_AL= L", os.environ.get("LC_CTYPE", os.environ.get("LANG", "POSIX"))))')" >> >> You're using python to get the exported env. =C2=A0Don't. =C2=A0Use bash= (you're >> invoking python from freaking bash after all)... > > Given variable can be set, but not exported. If the variable is set but not exported then it is local to the shell env. When bash goes to exec() python the local shell variables are not in the env; so os.environ() will not contain them. antarus@kyoto ~ $ foo=3DBAR antarus@kyoto ~ $ echo $foo BAR antarus@kyoto ~ $ python -c 'import os; print os.environ.get("foo")' None antarus@kyoto ~ $ export foo antarus@kyoto ~ $ python -c 'import os; print os.environ.get("foo")' BAR so how is this any different than: [[ -n $LC_TYPE ]] && locale=3D$LC_TYPE [[ -n $LC_ALL ]] && locale=3D$LC_ALL locale=3D${locale:-POSIX} if you want to keep it short; or the longer version with more ifs and less shell magic. Normally I'm not a big performance man myself; but this is in an eclass used by lots of packages; not just one ebuild. > >> bug 328047 is induced by a patch we add (it's not in upstream python). > > This patch comes from upstream. > > -- > Arfrever Frehtes Taifersar Arahesis >