Skip Menu |

This queue is for tickets about the Encode CPAN distribution.

Report information
The Basics
Id: 116629
Status: resolved
Priority: 0/
Queue: Encode

People
Owner: Nobody in particular
Requestors: 'spro^^*%*^6ut# [...] &$%*c
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Still can't turn off "does not map to Unicode" warnings
This is related to #88592. Encode still fails to honour the caller’s warning settings in some cases. As noted in perl ticket #128788, this script emits a warning erroneously: use open qw( :std :utf8 ); use strict; use warnings; no warnings 'utf8'; my $bytes = "Test\x{E5}End"; my $fn = 'test.txt'; open ( my $fh, '>:raw', $fn ) or die "Could not open file '$fn': $!"; print $fh $bytes; close $fh; open ( $fh, "<:encoding(utf-8)", $fn ) or die "Could not open file '$fn': $!"; my $str = do { local $/; <$fh> }; close $fh; The attached one-line patch to Encode.xs fixes it. It is not intended to be a final patch, but a diagnostic tool. I simply used a C debugger to trace where the warning was coming from. I don’t know whether there is other similar code in Encode.xs that needs similar treatment.
Subject: open_IcjZZ4h6.txt
diff --git a/Encode.xs b/cpan/Encode/Encode.xs index cd7f7d1..403ba21 100644 --- a/Encode.xs +++ b/Encode.xs @@ -400,7 +400,7 @@ process_utf8(pTHX_ SV* dst, U8* s, U8* e, SV *check_sv, else Perl_croak(aTHX_ ERR_DECODE_NOMAP, "utf8", uv); } - if (check & ENCODE_WARN_ON_ERR){ + if (check & ENCODE_WARN_ON_ERR && ckWARN_d(WARN_UTF8)){ if (encode) Perl_warner(aTHX_ packWARN(WARN_UTF8), ERR_ENCODE_NOMAP, uv, "utf8");
On Mon Aug 01 11:47:48 2016, SPROUT wrote: Show quoted text
> This is related to #88592. > > Encode still fails to honour the caller’s warning settings in some > cases. > > > As noted in perl ticket #128788, this script emits a warning > erroneously: > > use open qw( :std :utf8 ); > use strict; > use warnings; > no warnings 'utf8'; > my $bytes = "Test\x{E5}End"; > my $fn = 'test.txt'; > open ( my $fh, '>:raw', $fn ) or die "Could not open file '$fn': $!"; > print $fh $bytes; > close $fh; > open ( $fh, "<:encoding(utf-8)", $fn ) or die "Could not open file > '$fn': > $!"; > my $str = do { local $/; <$fh> }; > close $fh; > > The attached one-line patch to Encode.xs fixes it. It is not intended > to be a final patch, but a diagnostic tool. I simply used a C > debugger to trace where the warning was coming from. I don’t know > whether there is other similar code in Encode.xs that needs similar > treatment.
I have not looked into this very far. It may well be that PerlIO::encoding is at fault in asking for warnings inappropriately. (I haven’t even got to looking at its code.)