From: Rafael Garcia-Suarez Date: Mon, 8 Sep 2003 20:45:03 +0000 (+0000) Subject: A version of change #21073 that works. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=03aa69f98a1004fda52fa77f324e5463bea07c1e;p=p5sagit%2Fp5-mst-13.2.git A version of change #21073 that works. p4raw-link: @21073 on //depot/perl: b5a808db3c007cbb4159178941346ac3c6f968a7 p4raw-id: //depot/perl@21106 --- diff --git a/ext/PerlIO/scalar/scalar.xs b/ext/PerlIO/scalar/scalar.xs index 0d56ecc..193b99f 100644 --- a/ext/PerlIO/scalar/scalar.xs +++ b/ext/PerlIO/scalar/scalar.xs @@ -25,7 +25,7 @@ PerlIOScalar_pushed(pTHX_ PerlIO * f, const char *mode, SV * arg, if (arg) { if (SvROK(arg)) { s->var = SvREFCNT_inc(SvRV(arg)); - if (!SvPOK(s->var)) + if (!SvPOK(s->var) && SvTYPE(SvRV(arg)) > SVt_NULL) (void)SvPV_nolen(s->var); } else { diff --git a/ext/PerlIO/t/scalar.t b/ext/PerlIO/t/scalar.t index 58ef97f..01e12b0 100644 --- a/ext/PerlIO/t/scalar.t +++ b/ext/PerlIO/t/scalar.t @@ -10,7 +10,7 @@ BEGIN { } $| = 1; -print "1..24\n"; +print "1..25\n"; my $fh; my $var = "ok 2\n"; @@ -126,3 +126,15 @@ close $fh; { package P; sub TIESCALAR {bless{}} sub FETCH {"ok 24\n"} } tie $p, P; open $fh, '<', \$p; print <$fh>; + +# don't warn when writing to an undefined scalar + +{ + use warnings; + my $ok = 1; + local $SIG{__WARN__} = sub { $ok = 0; }; + open my $fh, '>', \my $scalar; + print $fh "foo"; + close $fh; + print $ok ? "ok 25\n" : "not ok 25\n"; +}