develooper Front page | perl.perl5.porters | Postings from November 2010

Re: [perl #79828] STDERR isn't being unlocalized when there's anunhandled exception.

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
November 28, 2010 17:37
Subject:
Re: [perl #79828] STDERR isn't being unlocalized when there's anunhandled exception.
Message ID:
AANLkTiks41mUMhFNLAhZAE-4B9qY5FbZJB+KscwRYGiK@mail.gmail.com
> STDERR isn't being unlocalized when there's an unhandled exception.  For
> example,
>
>     perl -E 'open my $h, ">", \$string; local *STDERR = $h; die "blah"'
>
> doesn't emit anything.  That's global scope you say?  The following shows the
> same problem:
>
>     sub foo {
>         die q<why doesn't this show up?>;
>     }
>
>     sub bar {
>         my $x;
>         open my $h, '>', \$x;
>         local *STDERR = $h;
>         foo();
>     }
>
>     bar();
>
> I expect STDERR to be delocalized before final exeption handling kicks in.

*There simply is no final exception handling*. If die can't find an
eval block in an outer scope it defaults to printing out the error and
exit()ing. This is documented in perlfunc#die. The stack being pop()ed
is only a consequence of that exit. Hence, the warning is being
written before the unpopping of the stack.

I agree it may be better to do final exception handling, but the
current behavior is correct in the sense that it works as advertised.

Leon

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About