Turns out that this:
perl -MCarp -le 'package Foo; eval { Carp::croak(1) }; print keys %Foo::;'
Would leave two new symbols in Foo, CARP_NOT and ISA. This commit
changes trusts_directly() to check if the symbols exists in the
stash before using them.
}
}
-our $VERSION = '1.29';
+our $VERSION = '1.30';
our $MaxEvalLen = 0;
our $Verbose = 0;
sub trusts_directly {
my $class = shift;
no strict 'refs';
- no warnings 'once';
- return @{"$class\::CARP_NOT"}
- ? @{"$class\::CARP_NOT"}
- : @{"$class\::ISA"};
+ my $stash = \%{"$class\::"};
+ for my $var (qw/ CARP_NOT ISA /) {
+ # Don't try using the variable until we know it exists,
+ # to avoid polluting the caller's namespace.
+ if ( $stash->{$var} && @{"$class\::$var"} ) {
+ return @{"$class\::$var"}
+ }
+ }
+ return;
}
if(!defined($warnings::VERSION) ||
use Config;
use IPC::Open3 1.0103 qw(open3);
-use Test::More tests => 61;
+use Test::More tests => 62;
sub runperl {
my(%args) = @_;
);
}
+{
+ package Foo::No::CARP_NOT;
+ eval { Carp::croak(1) };
+ ::is_deeply(
+ [ keys %Foo::No::CARP_NOT:: ],
+ [],
+ "Carp doesn't create CARP_NOT or ISA in the caller if they don't exist"
+ );
+}
+
# New tests go here
# line 1 "A"