develooper Front page | perl.perl5.porters | Postings from October 2012

Re: [perl #24067] IO::Handle::error doesn't report errors

Thread Previous
Jeff King
October 12, 2012 14:46
Re: [perl #24067] IO::Handle::error doesn't report errors
Message ID:
On Sun, Sep 30, 2012 at 06:14:05AM -0700, Aaron Crane via RT wrote:

> > However, on 5.14 and 5.16, I don't get the print failure message, even
> > though I still get the "errors: no":
> >
> > Does anyone know what has changed, for better or worse?
> I can reproduce the OP's results under 5.16 by increasing the constant
> 4096 to 8192.  I believe that's because of this commit that first went
> into 5.14:

I think my original test was flaky; it should flush explicitly rather
than assuming that print will flush. So this is more realistic for a
program that is trying to be careful about whether output succeeded:

  use IO::File;
  my $fh = new IO::File($ARGV[0], 'w');
  ($fh->print('a' x 4096) && $fh->flush) || print "print failed: $!\n";
  print "errors: " . ($fh->error() ? "yes ($!)" : "no") . "\n";

> But it does look like a bug to me that $fh->error returns false after
> $fh->print has failed.

Right, that's the main thing I was trying to report with the test.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About