In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/aef23d36b0f3054bfc2ce21268f7910643e5ec02?hp=6c4ca75d655dc560dfacf633c27f31f751e3f615>
- Log ----------------------------------------------------------------- commit aef23d36b0f3054bfc2ce21268f7910643e5ec02 Author: Tony Cook <[email protected]> Date: Wed Jun 21 17:07:17 2017 +1000 bump $PerlIO::scalar::VERSION M ext/PerlIO-scalar/scalar.pm commit 45ef9d4862027ad8552b2fe56b5f00f93a99f308 Author: Tony Cook <[email protected]> Date: Wed Jun 21 17:07:02 2017 +1000 (perl #131546) return a reasonable error code opening a read-only scalar M ext/PerlIO-scalar/scalar.xs M ext/PerlIO-scalar/t/scalar.t commit 54e7f0568525f0cb975a8aeecd0bae5c75829466 Author: Tony Cook <[email protected]> Date: Mon Jun 12 11:03:35 2017 +1000 (perl #131546) some notes on in-memory files for open() M pod/perlfunc.pod ----------------------------------------------------------------------- Summary of changes: ext/PerlIO-scalar/scalar.pm | 2 +- ext/PerlIO-scalar/scalar.xs | 2 +- ext/PerlIO-scalar/t/scalar.t | 4 +++- pod/perlfunc.pod | 7 +++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ext/PerlIO-scalar/scalar.pm b/ext/PerlIO-scalar/scalar.pm index bcbb56c7c6..0276f210d6 100644 --- a/ext/PerlIO-scalar/scalar.pm +++ b/ext/PerlIO-scalar/scalar.pm @@ -1,5 +1,5 @@ package PerlIO::scalar; -our $VERSION = '0.27'; +our $VERSION = '0.28'; require XSLoader; XSLoader::load(); 1; diff --git a/ext/PerlIO-scalar/scalar.xs b/ext/PerlIO-scalar/scalar.xs index 4c5d2c1cb1..5c2ff5f0d9 100644 --- a/ext/PerlIO-scalar/scalar.xs +++ b/ext/PerlIO-scalar/scalar.xs @@ -43,7 +43,7 @@ PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, && mode && *mode != 'r') { if (ckWARN(WARN_LAYER)) Perl_warner(aTHX_ packWARN(WARN_LAYER), "%s", PL_no_modify); - SETERRNO(EINVAL, SS_IVCHAN); + SETERRNO(EACCES, RMS_PRV); return -1; } s->var = SvREFCNT_inc(SvRV(arg)); diff --git a/ext/PerlIO-scalar/t/scalar.t b/ext/PerlIO-scalar/t/scalar.t index 3dfcced38d..bd06d641cd 100644 --- a/ext/PerlIO-scalar/t/scalar.t +++ b/ext/PerlIO-scalar/t/scalar.t @@ -13,10 +13,11 @@ BEGIN { } use Fcntl qw(SEEK_SET SEEK_CUR SEEK_END); # Not 0, 1, 2 everywhere. +use Errno qw(EACCES); $| = 1; -use Test::More tests => 122; +use Test::More tests => 123; my $fh; my $var = "aaa\n"; @@ -185,6 +186,7 @@ EOF my $ro = \43; ok(!(defined open(F, '>', $ro)), $!); + is($!+0, EACCES, "check we get a read-onlyish error code"); close F; # but we can read from it ok(open(F, '<', $ro), $!); diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index bb0383f2d6..b1e4ac2ed9 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -4530,6 +4530,13 @@ To (re)open C<STDOUT> or C<STDERR> as an in-memory file, close it first: open(STDOUT, ">", \$variable) or die "Can't open STDOUT: $!"; +The scalars for in-memory files are treated as octet strings: unless +the file is being opened with truncation the scalar may not contain +any code points over 0xFF. + +Opening in-memory files I<can> fail for a variety of reasons. As with +any other C<open>, check the return value for success. + See L<perliol> for detailed info on PerlIO. General examples: -- Perl5 Master Repository
