Skip to content

IO::Handle: Fix a spurious error reported for regular file handles #18035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist/IO/IO.xs
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ ferror(handle)
CODE:
if (in)
#ifdef PerlIO
RETVAL = PerlIO_error(in) || (in != out && PerlIO_error(out));
RETVAL = PerlIO_error(in) || (out && in != out && PerlIO_error(out));
#else
RETVAL = ferror(in) || (in != out && ferror(out));
RETVAL = ferror(in) || (out && in != out && ferror(out));
#endif
else {
RETVAL = -1;
Expand Down
10 changes: 9 additions & 1 deletion dist/IO/t/io_xs.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BEGIN {
}
}

use Test::More tests => 8;
use Test::More tests => 10;
use IO::File;
use IO::Seekable;

Expand Down Expand Up @@ -69,3 +69,11 @@ SKIP: {
ok(!$fh->error, "check clearerr removed the error");
close $fh; # silently ignore the error
}

{
# [GH #18019] IO::Handle->error misreported an error after successully
# opening a regular file for reading. It was a regression in GH #6799 fix.
ok(open(my $fh, '<', __FILE__), "a regular file opened for reading");
ok(!$fh->error, "no spurious error reported by error()");
close $fh;
}