From b17e32ea3ba5ef7362d2a3d1a433661afb897786 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Mon, 31 Mar 2014 15:43:51 -0600 Subject: [PATCH] PATCH: [perl #119499] "$!" with UTF-8 flag This disables the code that sets the UTF-8 flag when "$!" is UTF-8. This is being done to get v5.20 out the door, with changes to follow in v5.21. See towards the end of the discussion of this ticket. Unfortunately this change will cause #112208 to no longer be fixed. --- lib/locale.t | 8 ++++---- mg.c | 6 ++++++ pod/perldelta.pod | 8 +++++++- pod/perllocale.pod | 3 ++- pod/perlvar.pod | 4 ++++ 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/locale.t b/lib/locale.t index d1b7723..eea92e0 100644 --- a/lib/locale.t +++ b/lib/locale.t @@ -1613,15 +1613,15 @@ foreach my $Locale (@Locale) { $ok13 = $w == 0; # Look for non-ASCII error messages, and verify that the first - # such is in UTF-8 (the others almost certainly will be like the - # first). + # such is NOT in UTF-8 (the others almost certainly will be like + # the first) See [perl #119499]. $ok14 = 1; foreach my $err (keys %!) { use Errno; $! = eval "&Errno::$err"; # Convert to strerror() output my $strerror = "$!"; if ("$strerror" =~ /\P{ASCII}/) { - $ok14 = utf8::is_utf8($strerror); + $ok14 = ! utf8::is_utf8($strerror); last; } } @@ -1703,7 +1703,7 @@ foreach my $Locale (@Locale) { $problematical_tests{$locales_test_number} = 1; report_result($Locale, ++$locales_test_number, $ok14); - $test_names{$locales_test_number} = 'Verify that non-ASCII UTF-8 error messages are in UTF-8'; + $test_names{$locales_test_number} = 'Verify that non-ASCII UTF-8 error messages are NOT in UTF-8'; report_result($Locale, ++$locales_test_number, $ok15); $test_names{$locales_test_number} = 'Verify that a number with a UTF-8 radix has a UTF-8 stringification'; diff --git a/mg.c b/mg.c index 6a3a98a..76912bd 100644 --- a/mg.c +++ b/mg.c @@ -753,6 +753,11 @@ S_fixup_errno_string(pTHX_ SV* sv) if(strEQ(SvPVX(sv), "")) { sv_catpv(sv, UNKNOWN_ERRNO_MSG); } +#if 0 + /* This is disabled to get v5.20 out the door. It means that $! behaves as + * if in the scope of both 'use locale' and 'use bytes'. This can cause + * mixed encodings and double utf8 upgrading, See towards the end of the + * thread for [perl #119499] */ else { /* In some locales the error string may come back as UTF-8, in which @@ -773,6 +778,7 @@ S_fixup_errno_string(pTHX_ SV* sv) SvUTF8_on(sv); } } +#endif } #ifdef VMS diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 3cad7d7..78a5f39 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -378,7 +378,13 @@ files in F and F are best summarized in L. =item * -XXX +A regression involving the string value of C<$!> introduced in v5.19.2 +has been reverted for v5.20. +[L] +This re-breaks the bugs it fixed, +L, so +an alternative fix is planned for v5.22 + =back diff --git a/pod/perllocale.pod b/pod/perllocale.pod index 3a3d6f0..e239414 100644 --- a/pod/perllocale.pod +++ b/pod/perllocale.pod @@ -205,7 +205,8 @@ Only operations originating outside Perl should be affected, as follows: The variables L<$!|perlvar/$ERRNO> (and its synonyms C<$ERRNO> and C<$OS_ERROR>) and L<$^E|perlvar/$EXTENDED_OS_ERROR> (and its synonym C<$^E>) when used as strings always are in terms of the current -locale. +locale and as if within the scope of L<"use bytes"|bytes>. This is +likely to change in Perl v5.22. =item * diff --git a/pod/perlvar.pod b/pod/perlvar.pod index cc0cf04..039a098 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -1765,6 +1765,10 @@ It can be used immediately before invoking the C operator, to set the exit value, or to inspect the system error string corresponding to error I, or to restore C<$!> to a meaningful state. +Note that when stringified, the text is always returned as if both +S|perllocale>> and S|bytes>> are in +effect. This is likely to change in v5.22. + Mnemonic: What just went bang? =item %OS_ERROR -- 1.8.3.1