Skip to content

Commit

Permalink
import Safe 2.19 from CPAN
Browse files Browse the repository at this point in the history
git-cpan-module: Safe
git-cpan-version: 2.19
git-cpan-authorid: RGARCIA
  • Loading branch information
rgs authored and schwern committed Dec 6, 2009
1 parent 81ce476 commit d9f6798
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Changes
@@ -1,3 +1,9 @@
2.19 Tue Aug 25 2009
t/safeuniversal.t failure under 5.8.9 (Jerry D. Hedden)

2.18 released with perl 5.10.1
[perl #68530] "version::CLASS" warning in Safe.pm (Dave Mitchell)

2.17 Sun Jun 28 2009
Sync with code reorganisation in bleadperl
Plus new tests
Expand Down
2 changes: 1 addition & 1 deletion META.yml
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Safe
version: 2.17
version: 2.19
abstract: ~
license: ~
author: ~
Expand Down
6 changes: 4 additions & 2 deletions Safe.pm
Expand Up @@ -3,7 +3,7 @@ package Safe;
use 5.003_11;
use strict;

$Safe::VERSION = "2.17";
$Safe::VERSION = "2.19";

# *** Don't declare any lexicals above this point ***
#
Expand Down Expand Up @@ -243,13 +243,15 @@ sub share_from {
my ($var, $type);
$type = $1 if ($var = $arg) =~ s/^(\W)//;
# warn "share_from $pkg $type $var";
*{$root."::$var"} = (!$type) ? \&{$pkg."::$var"}
for (1..2) { # assign twice to avoid any 'used once' warnings
*{$root."::$var"} = (!$type) ? \&{$pkg."::$var"}
: ($type eq '&') ? \&{$pkg."::$var"}
: ($type eq '$') ? \${$pkg."::$var"}
: ($type eq '@') ? \@{$pkg."::$var"}
: ($type eq '%') ? \%{$pkg."::$var"}
: ($type eq '*') ? *{$pkg."::$var"}
: croak(qq(Can't share "$type$var" of unknown type));
}
}
$obj->share_record($pkg, $vars) unless $no_record or !$vars;
}
Expand Down
9 changes: 5 additions & 4 deletions t/safeuniversal.t
Expand Up @@ -22,8 +22,10 @@ plan(tests => 6);
my $c = new Safe;
$c->permit(qw(require caller));

my $r = $c->reval(q!
no warnings 'redefine';
my $no_warn_redef = ($] != 5.008009)
? q(no warnings 'redefine';)
: q($SIG{__WARN__}=sub{};);
my $r = $c->reval($no_warn_redef . q!
sub UNIVERSAL::isa { "pwned" }
(bless[],"Foo")->isa("Foo");
!);
Expand All @@ -33,8 +35,7 @@ is( (bless[],"Foo")->isa("Foo"), 1, "... but not outside" );

sub Foo::foo {}

$r = $c->reval(q!
no warnings 'redefine';
$r = $c->reval($no_warn_redef . q!
sub UNIVERSAL::can { "pwned" }
(bless[],"Foo")->can("foo");
!);
Expand Down

0 comments on commit d9f6798

Please sign in to comment.