Subject: | IO::All::encoding() fails for stdio objects |
Date: | Fri, 27 May 2011 14:21:10 -0400 |
To: | bug-IO-All [...] rt.cpan.org |
From: | Bernardo Rechea <brbpub [...] gmail.com> |
IO::All::encoding() calls
CORE::binmode($self->io_handle, ":$encoding") if $self->is_open;
which applies to stdio handles (preopened by perl).
If the io_handle is not opened, when IO::All::open() is called later it calls
$self->set_binmode;
which, in turns, calls:
CORE::binmode($self->io_handle, ":encoding($encoding)");
Thus the following catch-22: creating an IO::All object with a variable
name io($name), then setting the encoding, will fail for stdio (i.e., if
the supplied $name is '-' or '='); trying to work around this by setting
the encoding to 'encoding($myOrigEncoding)' will now fail for non-stdio
objects.
Changing
CORE::binmode($self->io_handle, ":$encoding")
to
CORE::binmode($self->io_handle, ":encoding($encoding)")
in encoding() to be consistent with what's done in set_binmode() fixes this bug.
Thanks.
Bernardo Rechea