Subject: | stray warning if output has no layers |
Date: | Mon, 17 Jul 2017 21:17:22 +0100 |
To: | bug-podlators [...] rt.cpan.org |
From: | Zefram <zefram [...] fysh.org> |
With Pod::Man 4.09, and some combination of related modules that I haven't
pinned down (possibly just a sufficiently old Pod::Perldoc), perldoc(1)
is producing a warning on stderr:
Use of uninitialized value $flag in bitwise and (&) at /home/zefram/usr/perl/perl_install/perl-5.16.0-i64-f52/lib/site_perl/5.16.0/Pod/Man.pm line 809.
The code around there, in ->start_document, is trying to determine
whether the output handle takes bytes or characters. It calls
PerlIO::get_layers() with the detail option set, takes the last item from
the returned list, and checks for a bit being set in it. It's expecting
to get the flags for the topmost layer. But in the cases that produce
the above warning, PerlIO::get_layers() is returning an empty list,
so undef is obtained instead of the expected flag set.
Everything else works; correct output is produced. By inserting test
statements into the code in question, I've established that the file
handle is an IO::File object, and is actually open and usable at that
point: extra text printed to it goes into the formatted output. I'm not
sure how a file handle gets to be usable while having no PerlIO layers.
I suspect that the code should just accept the no-layers situation as
meaning that the handle doesn't do UTF-8. The fix would be the insertion
of "|| 0" on the end of the expression assigned to $flag. But because
I don't understand the no-layers situation I'm not sure about this: it
might be that there's a UTF-8 flag somewhere that this code fails to read.
-zefram