Skip to content

Commit

Permalink
[perl #71002] stat() on unopened fh _
Browse files Browse the repository at this point in the history
stat _ was producing an erroneous warning about an unopened filehandle
with _.  But _ isn’t a real filehandle and is special-cased, so it
shouldn’t warn.

See also commit 8080e3c.
  • Loading branch information
Father Chrysostomos committed Jan 20, 2012
1 parent 0540b90 commit daa30a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pp_sys.c
Expand Up @@ -2796,10 +2796,10 @@ PP(pp_stat)
PL_laststatval = -1;
}
}
if (PL_laststatval < 0 && !havefp) report_evil_fh(gv);
}

if (PL_laststatval < 0) {
if (!havefp) report_evil_fh(gv);
max = 0;
}
}
Expand Down
12 changes: 11 additions & 1 deletion t/op/stat.t
Expand Up @@ -20,7 +20,7 @@ if(eval {require File::Spec; 1}) {
}


plan tests => 112;
plan tests => 113;

my $Perl = which_perl();

Expand Down Expand Up @@ -587,6 +587,16 @@ SKIP: {
}
}

# [perl #71002]
{
local $^W = 1;
my $w;
local $SIG{__WARN__} = sub { warn shift; ++$w };
stat 'prepeinamehyparcheiarcheiometoonomaavto';
stat _;
is $w, undef, 'no unopened warning from stat _';
}

END {
chmod 0666, $tmpfile;
unlink_all $tmpfile;
Expand Down

0 comments on commit daa30a6

Please sign in to comment.