fix: correct error returns in tied handle methods - #415
Draft
toddr-bot wants to merge 1 commit into
Draft
Conversation
WRITE (syswrite) now returns undef on all error conditions instead of 0, matching real Perl behavior where undef signals error and 0 means zero bytes written. READ (sysread) data-gone case also corrected. GETC and READLINE on write-only handles now set $! = EBADF in addition to warning, matching real Perl's errno behavior. Closes cpan-authors#351
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix incorrect error return values in
WRITE,READ,GETC, andREADLINEtied handle methods.Why
Real Perl
syswritereturnsundefon error (EBADF, EINVAL), where0means "zero bytes written". The tiedWRITEmethod was returning0for all error conditions, making errors indistinguishable from successful zero-byte writes when checkingdefined(syswrite(...)). Same issue inREADfor the data-gone (weakref destroyed) case. Additionally,getcandreadlineon write-only handles were warning correctly but not setting$! = EBADF, diverging from real Perl behavior.How
WRITE: all 4 error returns changed from0toundef(EBADF, EINVAL × 3)_write_bytes: data-gone return changed from0toundefREAD: data-gone return changed from0toundefGETC: added$! = EBADFbefore return on write-only handleREADLINE: added$! = EBADFbefore return on write-only handleTesting
undefinstead of0$! = EBADFassertions for readline (scalar + list) and getc on write-only handlesCloses #351
Quality Report
Changes: 7 files changed, 30 insertions(+), 22 deletions(-)
Code scan: clean
Tests: failed (4 Failed, 94 test)
Branch hygiene: clean
Generated by Kōan