Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'output': 0.05; '(python': 0.07; 'pypy': 0.07; 'python3': 0.07; 'wednesday,': 0.07; 'locale': 0.09; 'none)': 0.09; 'outlined': 0.09; 'subject:None': 0.09; 'python': 0.11; '2.7': 0.14; '"python': 0.16; '(none,': 0.16; '2.2.1': 0.16; '2.7.3': 0.16; 'called.': 0.16; 'surprises': 0.16; 'x86_64': 0.16; 'variable': 0.18; 'examples': 0.20; 'feb': 0.22; '>>>': 0.22; 'example': 0.22; 'import': 0.22; 'tests': 0.22; 'print': 0.22; 'this?': 0.23; 'skip:l 30': 0.24; 'environment': 0.24; 'equivalent': 0.26; 'first,': 0.26; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'skip:( 40': 0.30; 'code': 0.31; "skip:' 10": 0.31; '"")': 0.31; '>>>>': 0.31; 'gcc': 0.31; 'skip:= 20': 0.31; 'supposed': 0.32; 'another': 0.32; 'linux': 0.33; 'header:Received:9': 0.33; 'problem': 0.35; 'something': 0.35; 'but': 0.35; 'skip:> 10': 0.36; 'starting': 0.37; 'sometimes': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; '12,': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'even': 0.60; 'received:98.137': 0.60; 'march': 0.61; 'here:': 0.62; 'kind': 0.63; 'more': 0.64; 'here': 0.66; 'header :Reply-To:1': 0.67; 'mar': 0.68; 'to:addr:yahoo.com': 0.81; '2.7.': 0.84; '2014,': 0.84; 'system:': 0.91 X-Yahoo-Newman-Property: ymail-4 X-Yahoo-Newman-Id: 479941.35824.bm@omp1007.mail.gq1.yahoo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1394653227; bh=oZpwPQq4g0PYWEaBnAqJ6LHUzKHnk4LymL8JA2PKlJw=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=03Dhg1TIa8UKW/Xc7GZ2Uf6pIU1vpid4ljpCeftGAzGZobEJe+h75SXb6GWjsaLXyPRtWaujRbwrUW7ADebJytSrh32Sl2+UlaSB3nd7c07/i9tPa414kbftzPxWdq8/ED59lvdaZXadUdX64QP2BeCiYLQ6wmypCQCz5G4tkFQ= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=g+TtWvN6lNtFxBQe1COUYM6xmCgxUGhEgBuHTja2Q6+1uaC1Pn57SgDkRjROHfbsOcxUUZcbrNz3keNsB4BKXaV0uq/yarhDPF5KWjJR0nB6OH+FZrbf+87pMUuVDCyZA1AS474D7tEbr5XwEh3GRFEyngptNTvq/Af9EQ9t510=; X-YMail-OSG: 5Ob.jzQVM1klOWP.FFL0nbrjGIDN7gKcxV.07pdC7L9RzJw .g69u0LowQ7.ZvVYXFlFoNTV8rvbdRx.D7BjInWFogGKCcfeBD2Ua36Lqj0u KwQQoAX6ODMge.hUPP5PWEcA1UlDYSaGUxNRaVWsksYEhkn2rRA68J.6BD0V zz47RGkqcf41UuL4kpXOwuL7SJXxWLXY4Dm2WPV0qaiVdgaRQA7fAkC5FvQD xwfNfDZwvI7bM6Ak_4PxQL2h.KuWPuXzlxTL1k3qCofFMeStffBRHdydMXUn VDqlPeZ5tb8.fjCrkrgMnnrpKYiGtfxYXDRqebgij6jWytIr5XFORn5cwTLW 2qlfNLOfj6_AKAwZa3jg.auel9KRfzOFCXSHhZ9WFu9Wofiw6Ojz7Un5Jyo7 gwWU51PitJFQIqrabsGEmIYjfsU58tCESOE5b7Ezm0EquAmQ2f08aUh.poYj S8Nxbi4QryLyDL4dC90WZrx7YntJWAduyoN.zEos_rs5KKd1dlUitJKFBId. U.2Vt2VEyXuG7Kn.OeDJaKBchi211480z3QnkiUfsnb2s85b3UOQOd60CpF6 .gGb5yDCY5S11zdJ.twdjnVuUVcJVxbMy0EBBJwsCY6lRMAkba3jow0vl4X5 3k9tnRrVvBlWtbu4yPv07YS7fejuXfiQtwGMNS5QR.oXHsp2UbzUpimHgwuc zTPdY90.Bt03Syvp0f6cIQaV_5eSmugPxbhWKfbPORVE- X-Rocket-MIMEInfo: 002.001, Cgo.X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KPiBGcm9tOiBBbGJlcnQtSmFuIFJvc2thbSA8Zm9tY2xAeWFob28uY29tPgo.VG86IFB5dGhvbiA8cHl0aG9uLWxpc3RAcHl0aG9uLm9yZz4gCj5TZW50OiBXZWRuZXNkYXksIE1hcmNoIDEyLCAyMDE0IDE6MjIgUE0KPlN1YmplY3Q6IGxvY2FsZSBnZXRsb2NhbGUgcmV0dXJucyBOb25lIG9uIE9TWAo.IAo.Cj5IaSwKPgo.bG9jYWxlLmdldGxvY2FsZSgpIHNvbWV0aW1lcyByZXR1cm5zIChOb25lLCBOb25lKSB1bmRlciBPU1ggKFB5dGhvbiAyLCABMAEBAQE- X-Mailer: YahooMailWebService/0.8.177.636 References: <1394626979.46880.YahooMailBasic@web163806.mail.gq1.yahoo.com> Date: Wed, 12 Mar 2014 12:40:27 -0700 (PDT) From: Albert-Jan Roskam Subject: Re: locale getlocale returns None on OSX To: Albert-Jan Roskam , Python In-Reply-To: <1394626979.46880.YahooMailBasic@web163806.mail.gq1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Albert-Jan Roskam List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1394653528 news.xs4all.nl 2936 [2001:888:2000:d::a6]:39674 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68294 =0A=0A>________________________________=0A> From: Albert-Jan Roskam =0A>To: Python =0A>Sent: Wednesday, Marc= h 12, 2014 1:22 PM=0A>Subject: locale getlocale returns None on OSX=0A> =0A= >=0A>Hi,=0A>=0A>locale.getlocale() sometimes returns (None, None) under OSX= (Python 2, not sure about Python 3, but I think so). The problem is outlin= ed here:=0A>http://stackoverflow.com/questions/1629699/locale-getlocale-pro= blems-on-osx=0A>=0A>What is the cause of this? Is it limited to just Darwin= systes? Does the 'horrible hack' solution on OS have any drawbacks? I like= it better because it is not needed to set the LC_ALL environment variable = prior to starting the Python program.=0A>=0A>Regards,=0A>=0A>Albert-Jan=0A= =0A=0AOk, here are some tests on my own system:=0A=0Aalbertjan@debian:~$ un= ame -a=0ALinux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux= =0A=0A=0AEven if locale.setlocale is used first, OSX returns (None, None) w= hen locale.getlocale() is called. Another thing that surprises me in the ex= amples below is the output of the "python -c" example using Python 2.7. Isn= 't this supposed to be exactly equivalent to the code that follows?=0A=0A= =0A=0A# =3D=3D=3D=3D=3D=3D=3D=3D Python 2.7 =3D=3D=3D=3D=3D=3D=3D=3Dalbertj= an@debian:~$ python -c "import locale; locale.setlocale(locale.LC_ALL, "");= print(locale.getlocale())"=0A=0A(None, None)=A0=A0 # <---- why is this?=0A= =0A=0Aalbertjan@debian:~$ python=0APython 2.7.3 (default, Jan=A0 2 2013, 13= :56:14) =0A[GCC 4.7.2] on linux2=0AType "help", "copyright", "credits" or "= license" for more information.=0A>>> import locale=0A>>> locale.setlocale(l= ocale.LC_ALL, "")=0A'en_US.UTF-8'=0A>>> locale.getlocale()=0A('en_US', 'UTF= -8')=A0 # <--- OSX (sometimes?) returns (None, None) here.=0A=0A=0A=0A# =3D= =3D=3D=3D=3D=3D=3D=3D Python 3.3 =3D=3D=3D=3D=3D=3D=3D=3D=0Aalbertjan@debia= n:~$ python3 -c "import locale; locale.setlocale(locale.LC_ALL, ""); print(= locale.getlocale())"=0A('en_US', 'UTF-8')=0A=0Aalbertjan@debian:~$ python3= =0APython 3.3.4 (default, Feb 17 2014, 19:23:00) =0A[GCC 4.7.2] on linux=0A= Type "help", "copyright", "credits" or "license" for more information.=0A>>= > import locale=0A>>> locale.setlocale(locale.LC_ALL, "")=0A'en_US.UTF-8'= =0A>>> locale.getlocale()=0A('en_US', 'UTF-8')=0A=0A=0A=0A# =3D=3D=3D=3D=3D= =3D=3D=3D Pypy =3D=3D=3D=3D=3D=3D=3D=3D=0Aalbertjan@debian:~$ pypy -c "impo= rt locale; locale.setlocale(locale.LC_ALL, ""); print locale.getlocale()"= =0A(None, None)=0A=0Aalbertjan@debian:~$ pypy=0A=0APython 2.7.3 (87aa9de10f= 9ca71da9ab4a3d53e0ba176b67d086, Mar 10 2014, 14:07:15)=0A[PyPy 2.2.1 with G= CC 4.7.2] on linux2=0AType "help", "copyright", "credits" or "license" for = more information.=0AAnd now for something completely different: ``pypy is a= better kind of=0Afoolishness - lac''=0A>>>> import locale=0A>>>> locale.se= tlocale(locale.LC_ALL, "")=0A'en_US.UTF-8'=0A>>>> locale.getlocale()=0A('en= _US', 'UTF-8')