develooper Front page | perl.perl5.porters | Postings from July 2013

Re: [perl #118795] locale changes in 5.19.1 break LC_NUMERIC handling

Thread Previous | Thread Next
From:
John Peacock
Date:
July 9, 2013 23:00
Subject:
Re: [perl #118795] locale changes in 5.19.1 break LC_NUMERIC handling
Message ID:
51DC9600.7080204@havurah-software.org
On 07/09/2013 12:18 AM, Karl Williamson wrote:
> Nor was this done without warning to programmers.  Near the very
> beginning of perl5191delta, under "Incompatible Changes", it says

Ah, ha, that's where it is.  Putting LC_NUMERIC in that block would have 
made it much easier to spot using grep...

> But perhaps you meant that there is no run-time warning or error about
> calling setlocale outside the scope of 'use locale'.  Such a warning
> would only be appropriate if setlocale were called with LC_NUMERIC, as
> there is no change in any behavior here for the other categories.

There is no such documentation associated with the POSIX::setlocale() 
function itself, which is the only thing I thought to check.  I had no 
idea I had to look in perllocale and locale and ultimately perl5191delta 
to understand what was going on.  This is just as much 
action-at-a-distance as the old behaviour was, and in some ways worse, 
because there is very little way (short of raising a stink on p5p) that 
anyone would know about it.  Most non-p5p'ers don't read perl*delta for 
fun and profit.

If you are going to go and fix an inconsistency with locale related 
code, shouldn't you also document that in the one function in the Perl 
core where you can change locales in a running script?

> Further, some uses of LC_NUMERIC prior to this change did obey scoping
> rules, so the warning would be wrong in some cases even here.  Also, it
> is legitimate to call setlocale with no intention of ever doing 'use
> locale' if one is just using POSIX functions, though that is unlikely.

If I call setlocale() with anything other than an empty string as the 
second parameter, shouldn't I reasonably expect _something_ to happen? 
Or be warned that nothing is going to happen because I didn't add the 
undocumented 'use locale' line?

> So, it's not that the behavior of the system has changed monolithically
> around setlocale, 'use locale'.  It's that things now behave more
> consistently across the possible parameters to setlocale().

Thank you for the excellent summary of why you did what you did.  I'm 
glad that this happened early in the development cycle so we can fix up 
the tests and improve the documentation before production code is involved.

John

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About