[LA.pm] Wide character warnings from Test::Builder

Kevin Scaldeferri kevin at scaldeferri.com
Tue May 25 11:48:00 CDT 2004


Geoffrey Young wrote:

>>However, I'd really like to understand what's going on here.  There
>>really shouldn't be any warning printed and I can't figure out what the
>>funny business is that's going on inside Test::Builder.
>>    
>>
>
>it's not funny business, but rather the results from a typical use of warnings:
>
>$ perl -e 'use warnings; print "\x{B514}\x{C790}\x{C778} \x{BA85}\x{D568}"'
>Wide character in print at -e line 1.
>...
>
>  
>
It would be, but I'm in a locale that understands wide characters. So, 
for me, that command doesn't print a warning. Similarly, if I just print 
the string in my test case, there is no warning.


>no warnings qw(utf8) gets rid of it, but the warnings pragma isn't supposed
>to work at a distance like we want it to.  you might try
>
>  local $^W=0;
>
>but that will suppress all warnings, not just the utf8 ones, which is kinda
>against the point if you care about these kind of things.
>


And, it doesn't actually seem to block this warning :-(


Something really odd seems to happen in Test::Builder, although the code 
looks fairly straightforward. Even if I grab the filehandle and 
explicitly binmode it, I still get the warning:

=====================
#!/usr/local/bin/perl

use strict;

use Test::More tests => 1;
use Test::Builder;

my $korean = "\x{B514}\x{C790}\x{C778} \x{BA85}\x{D568}";

ok(1, $korean);
print("---\n");
print($korean,"\n");
print("---\n");

#Test::Builder is a singleton, so this should be the exact same filehandle
my $fh =Test::Builder->new()->output() ;
binmode($fh,":utf8");
print $fh $korean, "\n";
======================
[kevin]% perl foo.t
1..1
Wide character in print at /usr/lib/perl5/5.8.0/Test/Builder.pm line 894.
ok 1 - 디자인 명함
---
디자인 명함
---

Wide character in print at /home/kevin/bin/foo.t line 26.
디자인 명함
===============


I tried pulling a bunch of code out of Test::Builder and doing exactly 
the same filehandle and input manipulations they do and I couldn't 
reproduce the warning outside of that module.

-kevin



More information about the Losangeles-pm mailing list