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

[perl #119499] $! returned with UTF-8 flag under UTF-8 locales only under 5.19.2+

Thread Previous | Thread Next
From:
Victor Efimov via RT
Date:
September 16, 2013 16:55
Subject:
[perl #119499] $! returned with UTF-8 flag under UTF-8 locales only under 5.19.2+
Message ID:
rt-3.6.HEAD-1873-1379350499-760.119499-15-0@perl.org
So, you propose:
1. in scope of 'use locale' implement old behaviour (5.18 and earlier)
2. outside of scope - "decode fully, as best as practicable on the
platform being run on"

I don't think this will solves the problem.

Existing programs will still break (and to fix it you'll need to add
'use locale', which can introduce other bugs to program).

Existing programs might work with modern unicode and, AFAIK, adding 'use
locale' just not recommended for this case. The fact that they
use '$!' is not necessary means it's legacy code which don't work with
unicode. It can be brand new code written for 5.18

Also, @Zefram mentioned here
https://rt.perl.org/rt3/Ticket/Display.html?id=119499#txn-1250019 that
lexical scope for such things isn't a good idea.

> decode fully, as best as practicable on the platform being run on

function, which sometimes returns character string with UTF-8 bit set,
and sometimes returns byte string in unknown encoding is useless IMHO.
so if you decode $!, decoding should be done always. if decoding is
failed, IMHO better to return undef or something.


On Mon Sep 16 09:05:17 2013, public@khwilliamson.com wrote:
> On 09/09/2013 07:06 PM, Karl Williamson wrote:
> > On 09/02/2013 05:10 PM, Victor Efimov wrote:
> >>
> >> 2013/9/1 Father Chrysostomos via RT <perlbug-followup@perl.org
> >> <mailto:perlbug-followup@perl.org>>
> >>
> >>     A new global variable is another option.
> >>
> >> perhaps ${^DECODED_ERROR} ?
> >
> >
> > I have come to believe that this is probably the best way forward.  That
> > is, revert the $! change, and tell people who need it to use the new
> > global variable which will decode as best it can on the given platform
> > based on the locale in effect.
> >
> 
> In looking at this, I thought of something else.  I do believe that the 
> current behavior is correct for such a variable within the lexical scope 
> of "use locale".  But outside such scope the behavior would be to decode 
> fully, as best as practicable on the platform being run on.
> 
> Then it occurred to me would merely changing $! (and $^E) to behave this 
> way address your issues?  It is a change in behavior from the way things 
> have alway been, but outside "use locale", it would fully decode, which 
> someone in the thread was the issue with the current fix.
> 




---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=119499

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