Open p5pRT opened 11 years ago
IO::File->open() isn't affected by use open(:std :utf8). I understand that use open() is lexical in scope\, but IO::File's open could at least present a warning. And if that's not possible the documentation for IO::File should be changed.
Schwern suggests this is related to autodie\, and can be fixed in a similar manner. If it cannot be fixed\, then an error message or warning would be very welcome (and would have saved a great deal of frustration).
See also:
http://stackoverflow.com/questions/14595624/perls-iofile-and-use-open-qwutf8/14595721
https://rt.cpan.org/Public/Bug/Display.html?id=54777
Here is a test case:
#!/usr/local/bin/perl
use utf8; use v5.16; use strict; use warnings; use warnings qw(FATAL utf8); use diagnostics; use open qw(:std :utf8); use charnames qw(:full :short);
use Test::More tests => 3;
my $str = "Hello ȓ (r-caret)";
eval { open(my $fh\, '\<'\, \$str); print while ($_ = $fh->getc()); close($fh); pass("read utf from opened string"); }; if ($@) { fail("read utf8 from opened() string"); }
eval { use IO::File; my $fh = IO::File->new(); $fh->open(\$str\, '\<'); print while ($_ = $fh->getc()); $fh->close(); pass("read utf8 from IO::File->open() string"); }; if ($@) { fail("read utf8 from IO::File->open() string"); }
eval { use IO::File; my $fh = IO::File->new(); $fh->open(\$str\, '\<:encoding(UTF-8)'); print while ($_ = $fh->getc()); $fh->close(); pass("read utf8 from IO::File->open() string with encoding"); }; if ($@) { fail("read utf8 from IO::File->open() string with encoding"); }
On Wed\, Jan 30\, 2013 at 7:18 PM\, Michael Joyce \perlbug\-followup@​perl\.org wrote:
IO::File->open() isn't affected by use open(:std :utf8). I understand that use open() is lexical in scope\, but IO::File's open could at least present a warning. And if that's not possible the documentation for IO::File should be changed.
First of all\, why are you using IO::File? I can't think of any advantage it has over regular open (unless you're still on perl 5.005)\, and many disadvantages (specially poor support for PerlIO layers). You really don't want to use it anymore.
Schwern suggests this is related to autodie\, and can be fixed in a similar manner. If it cannot be fixed\, then an error message or warning would be very welcome (and would have saved a great deal of frustration).
Well yeah\, it probably can. I'm not entirely sure it should\, given IO::File is visibly non-lexical (unlike autodie\, which acts as if it is lexical).
Leon
The RT System itself - Status changed from 'new' to 'open'
On 2013-01-30\, at 10:37 AM\, Leon Timmermans via RT \perlbug\-followup@​perl\.org wrote:
On Wed\, Jan 30\, 2013 at 7:18 PM\, Michael Joyce \perlbug\-followup@​perl\.org wrote:
IO::File->open() isn't affected by use open(:std :utf8). I understand that use open() is lexical in scope\, but IO::File's open could at least present a warning. And if that's not possible the documentation for IO::File should be changed.
First of all\, why are you using IO::File? I can't think of any advantage it has over regular open (unless you're still on perl 5.005)\, and many disadvantages (specially poor support for PerlIO layers). You really don't want to use it anymore.
I found it while reading the documentation\, and it seemed to do what I needed. If it's depreciated\, I didn't see that mentioned anywhere in the POD or on CPAN.
Schwern suggests this is related to autodie\, and can be fixed in a similar manner. If it cannot be fixed\, then an error message or warning would be very welcome (and would have saved a great deal of frustration).
Well yeah\, it probably can. I'm not entirely sure it should\, given IO::File is visibly non-lexical (unlike autodie\, which acts as if it is lexical).
Leon
On Wed\, Jan 30\, 2013 at 8:38 PM\, Michael Joyce \michael@​negativespace\.netwrote:
On 2013-01-30\, at 10:37 AM\, Leon Timmermans via RT \< perlbug-followup@perl.org> wrote:
On Wed\, Jan 30\, 2013 at 7:18 PM\, Michael Joyce \perlbug\-followup@​perl\.org wrote:
IO::File->open() isn't affected by use open(:std :utf8). I understand that use open() is lexical in scope\, but IO::File's open could at least present a warning. And if that's not possible the documentation for IO::File should be changed.
First of all\, why are you using IO::File? I can't think of any advantage it has over regular open (unless you're still on perl 5.005)\, and many disadvantages (specially poor support for PerlIO layers). You really don't want to use it anymore.
I found it while reading the documentation\, and it seemed to do what I needed. If it's depreciated\, I didn't see that mentioned anywhere in the POD or on CPAN.
I'm working on perlopentut at the moment\, in which doc have you seen IO::File? perlopentut doesn't mention it.
Schwern suggests this is related to autodie\, and can be fixed in a similar manner. If it cannot be fixed\, then an error message or warning would be very welcome (and would have saved a great deal of frustration).
Well yeah\, it probably can. I'm not entirely sure it should\, given IO::File is visibly non-lexical (unlike autodie\, which acts as if it is lexical).
Leon
On Fri\, Feb 1\, 2013 at 10:11 PM\, Alexander Hartmaier \alex\.hartmaier@​gmail\.com wrote:
I found it while reading the documentation\, and it seemed to do what I needed. If it's depreciated\, I didn't see that mentioned anywhere in the POD or on CPAN.
I'm working on perlopentut at the moment\, in which doc have you seen IO::File? perlopentut doesn't mention it.
perlfunc open mentions it as an alternative. In general\, it should be updated to modern practices just as much as perlopentut does.
Leon
Migrated from rt.perl.org#116599 (status was 'open')
Searchable as RT116599$