Subject: | t/unicode.t fails if Locale::Encode is not available: Wide character in print |
Since EU::MM 7.00, Locale::Encode module is bundled (is that necessary, will it become a core module?). If I unbundle the module and remove it from the system as it's optional everywhere in the EU::MM, t/unicode.t from 7.02 fails:
$ prove -l -v t/unicode.t
t/unicode.t ..
1..9
ok 1 - setup
ok 2 - chdir'd to Problem-Module
# Locale env vars: LANG=en_US.UTF-8
not ok 3 - no warning
ok 4 - utf8 abstract
# Failed test 'no warning'
# at t/unicode.t line 49.
# got: '3'
# expected: '0'
# Wide character in print at /home/test/fedora/perl-ExtUtils-MakeMaker/ExtUtils-MakeMaker-7.02/lib/ExtUtils/MakeMaker.pm line 1202.
# Wide character in print at /home/test/fedora/perl-ExtUtils-MakeMaker/ExtUtils-MakeMaker-7.02/lib/ExtUtils/MakeMaker.pm line 1202.
# Wide character in print at /home/test/fedora/perl-ExtUtils-MakeMaker/ExtUtils-MakeMaker-7.02/lib/ExtUtils/MakeMaker.pm line 1202.
ok 5 - Exit code of make == 0
[...]
The line 1202 is the print in this code:
unlink($finalname, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : ());
open(my $fh,">", "MakeMaker.tmp")
or die "Unable to open MakeMaker.tmp: $!";
binmode $fh, ':encoding(locale)' if $CAN_DECODE;
for my $chunk (@{$self->{RESULT}}) {
my $to_write = "$chunk\n";
if (!$CAN_DECODE && $] > 5.008) {
utf8::encode $to_write;
}
print $fh "$chunk\n"
or die "Can't write to MakeMaker.tmp: $!";
}
The fix is to print the $to_write instead of the $chunk. It looks like an overlooking because this branch happens only Locale::Encode is not available.