[Pythonmac-SIG] How badly is _locale broken?

Brett C. bac at OCF.Berkeley.EDU
Fri Dec 31 09:00:59 CET 2004


Bob Ippolito wrote:
> On Dec 29, 2004, at 5:32 AM, Ronald Oussoren wrote:
>>
>> I know that. But not linking with CoreServices should fix _locale for 
>> python scripts that don't use mac-specific features.
> 
> 
> Well, my patch to remove all non-libSystem dependencies from the Python 
> core was accepted for Python 2.4, so we are already at this point.  
> However, the mac toolbox functions can lazily import CF-using modules.  
> I think the core probably uses some of these functions.  Last I 
> remember, the locale module itself linked to CF (directly or indirectly) 
> so it could guess what the current locale should be :)
> 

It is directly linked against CoreFoundation (there is function called 
mac_getstcript() in the extension module that is used to implement 
locale.getdefaultlocale .

>> The correct fix would probably use CFLocale to implement the _locale 
>> module on OSX.
> 
> 
> Yes, that would be a good fix.
> 

Right.  As I said I want to use CFNumberFormatter with CFLocale objects to fill 
in the dict returned by locale.localeconv as best as possible.

> Alternatively, we could just punt on the issue and say "you need to use 
> 10.X in order to have a working locale module", where 10.X is the 
> version that Apple fixes CF.  X is obviously greater than 3, but I don't 
> think it will be much greater.  It's been broken for this long, and 
> Brett C. said he doesn't use the locale module, so it may be too much 
> effort for too little reward.
> 

I have figured out the mapping of attributes from CFNumberFormatter to 
locale.localeconv, so doing that shouldn't be too painful.  The only serious 
problem was going to be if there was more breakage (such as strcoll and such) 
that needed fixing.  Dealing with localeconv so that test_locale stops failing 
(which, as a test, is really weak) should not be too bad.

And just leaving 10.3 users out in the cold seems slightly mean, even when 10.4 
comes out (due out in 2005, right?).

Normally I would say we should just have the entire locale module just raise an 
exception if it is imported on a version that has this problem, but nl_langinfo 
actually works so that seems extreme.  So I think I will go ahead and fix 
localeconv and see what 10.4 fixes when it comes out.

-Brett


More information about the Pythonmac-SIG mailing list