Skip to content

fix: Warn on print/say to read-only filehandle - Text::CSV 100% pass#439

Merged
fglock merged 1 commit intomasterfrom
feature/text-csv-phase10
Apr 4, 2026
Merged

fix: Warn on print/say to read-only filehandle - Text::CSV 100% pass#439
fglock merged 1 commit intomasterfrom
feature/text-csv-phase10

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 4, 2026

Summary

  • print/say to read-only filehandle now properly warns Filehandle opened only for input and returns undef, matching Perl 5 behavior
  • Warning uses the io category, respecting $^W, use warnings, and no warnings 'io'
  • Sets $! to Bad file descriptor (errno 9 / EBADF)
  • Catches NonWritableChannelException thrown by Java NIO when writing to a FileChannel opened for reading

Impact

This was the last remaining Text::CSV failure: t/70_rt.t test 72 expected a warning when $csv->print($fh, [...]) writes to a read-only filehandle via IO::Handle->print.

Text::CSV results: 40/40 test files pass, 52723/52723 subtests (100%)

Test plan

  • make passes (all unit tests)
  • Direct print $fh ... to read-only fh warns with $^W=1
  • IO::Handle->print to read-only fh warns with $^W=1
  • No warning without $^W/use warnings
  • Returns undef in all cases (matching Perl 5)
  • Text::CSV t/70_rt.t 20469/20469 (was 20468/20469)
  • Full Text::CSV suite: 40/40 files, 52723/52723 subtests

Generated with Devin

When printing to a filehandle opened for reading only, the builtin
print and say now set errno to Bad file descriptor, emit the warning
(when warnings enabled via io category), and return undef.

This was the last remaining Text::CSV failure: t/70_rt.t test 72.
All 40 Text::CSV test files now pass (52723/52723 subtests).

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock merged commit f8fdb5e into master Apr 4, 2026
2 checks passed
@fglock fglock deleted the feature/text-csv-phase10 branch April 4, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant