develooper Front page | perl.perl5.porters | Postings from June 2013

[perl #117989] Stop Carp from polluting the caller's namespace

Thread Previous
From:
Father Chrysostomos via RT
Date:
June 9, 2013 21:44
Subject:
[perl #117989] Stop Carp from polluting the caller's namespace
Message ID:
rt-3.6.HEAD-2552-1370814240-184.117989-15-0@perl.org
On Sat May 25 20:00:14 2013, jkeenan wrote:
> On Mon May 13 12:58:21 2013, Hugmeir wrote:
> > This is a bug report for perl from fraserbn@gmail.com,
> > generated with the help of perlbug 1.39 running under perl 5.16.2.
> > 
> > 
> > -----------------------------------------------------------------
> > [Please describe your issue here]
> > 
> > In perl 5.6, this:
> > 
> > perl -MCarp -le 'package Foo; eval { Carp::croak(1) }; print keys
> > %Foo::;'
> > 
> > Used to output 'ISA'. In 5.8 and newer, it outputs "ISA" and
> > "CARP_NOT".
> > This is because Carp::trusts_directly() simply tries using both
> > of those variables without checking if they exists first, which
> > ends up creating them.
> > The first of the attached patches fixes that

Thank you.  Applied as 1a4f8f4.

> > so that no new globs are
> > introduced to the caller's namespace, by checking if the variable
> > exists in the stash before using them.
> > 
> > The second patch fixes a related issue:

Applied as 79f8d0e.

> > 
> >     use Carp;
> >     package Foo;
> >     $CARP_NOT = 1;
> >     warn *{$Foo::{CARP_NOT}}{ARRAY} || 'undefined';
> >     eval { Carp::croak(1) };
> >     warn *{$Foo::{CARP_NOT}}{ARRAY} || 'undefined';
> > 
> > Both should display "undefined", but instead the second warn
> > shows that the array slot got vivified by Carp.
> > 
> 
> The patches look good.  The code changes are plausible.  Tests have been
> added.   The commit messages are descriptive.
> 
> However, when I applied the patch in a branch, I got a test failure:
> #####
> $ cd t;./perl harness -v ../dist/Carp/t/heavy.t; cd -
> ../dist/Carp/t/heavy.t .. 
> 1..3
> ok 1 # control
> ok 2 # carp loaded by Carp::Heavy
> not ok 3 # version numbers match
> Failed 1/3 subtests 
> 
> Test Summary Report
> -------------------
> ../dist/Carp/t/heavy.t (Wstat: 0 Tests: 3 Failed: 1)
>   Failed test:  3
> Files=1, Tests=3,  0 wallclock secs ( 0.00 usr +  0.01 sys =  0.01 CPU)
> Result: FAIL
> #####
> Now, this is another case of a (mindless, IMO) error in which a test is
> comparing version numbers in two different files.  What makes it
> particularly peculiar in this instance is that there's nothing in
> Carp::Heavy any more *except* its version number!
> 
> In any event, I am attaching an additional patch which I believe
> resolves this.  Please review.

Thank *you*, too.  Applied as 1ef9e4d.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=117989

Thread Previous


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