From: Matt S Trout Date: Sat, 11 Feb 2012 19:34:33 +0000 (+0000) Subject: revert local $\@ around require to avoid eating errors X-Git-Tag: v0.009014~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=faa9ce11cefee1e6f7800ec1dbe561717c162161;p=gitmo%2FMoo.git revert local $\@ around require to avoid eating errors --- diff --git a/Changes b/Changes index ba4b3c5..5de6ac9 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,4 @@ + - Revert 'local $@' around require calls to avoid triggering Unknown Error - Explicitly require Role::Tiny in Role::Tiny::With (RT#70446) 0.009013 - 2011-12-23 diff --git a/lib/Method/Generate/Accessor.pm b/lib/Method/Generate/Accessor.pm index 204330b..4a8ecd3 100644 --- a/lib/Method/Generate/Accessor.pm +++ b/lib/Method/Generate/Accessor.pm @@ -372,7 +372,7 @@ sub _generate_simple_set { my $simple = "${me}->{${name_str}} = ${value}"; if ($spec->{weak_ref}) { - { local $@; require Scalar::Util; } + require Scalar::Util; # Perl < 5.8.3 can't weaken refs to readonly vars # (e.g. string constants). This *can* be solved by: @@ -387,7 +387,7 @@ sub _generate_simple_set { eval { Scalar::Util::weaken($simple); 1 } or do { if( \$@ =~ /Modification of a read-only value attempted/) { - { local \$@; require Carp; } + require Carp; Carp::croak( sprintf ( 'Reference to readonly value in "%s" can not be weakened on Perl < 5.8.3', $name_str, diff --git a/lib/Method/Generate/Constructor.pm b/lib/Method/Generate/Constructor.pm index c11cbd2..95cbe88 100644 --- a/lib/Method/Generate/Constructor.pm +++ b/lib/Method/Generate/Constructor.pm @@ -55,7 +55,7 @@ sub generate_method { $body .= ' my $new = '.$self->construction_string.";\n"; $body .= $self->_assign_new($spec); if ($into->can('BUILD')) { - { local $@; require Method::Generate::BuildAll; } + require Method::Generate::BuildAll; $body .= Method::Generate::BuildAll->new->buildall_body_for( $into, '$new', '$args' ); diff --git a/lib/Moo.pm b/lib/Moo.pm index f188c12..aea43e1 100644 --- a/lib/Moo.pm +++ b/lib/Moo.pm @@ -20,7 +20,7 @@ sub import { @{*{_getglob("${target}::ISA")}{ARRAY}} = @_; }; *{_getglob("${target}::with")} = sub { - { local $@; require Moo::Role; } + require Moo::Role; die "Only one role supported at a time by with" if @_ > 1; Moo::Role->apply_role_to_package($target, $_[0]); }; @@ -28,7 +28,7 @@ sub import { *{_getglob("${target}::has")} = sub { my ($name, %spec) = @_; ($MAKERS{$target}{accessor} ||= do { - { local $@; require Method::Generate::Accessor; } + require Method::Generate::Accessor; Method::Generate::Accessor->new })->generate_method($target, $name, \%spec); $class->_constructor_maker_for($target) @@ -36,14 +36,14 @@ sub import { }; foreach my $type (qw(before after around)) { *{_getglob "${target}::${type}"} = sub { - { local $@; require Class::Method::Modifiers; } + require Class::Method::Modifiers; _install_modifier($target, $type, @_); }; } { no strict 'refs'; @{"${target}::ISA"} = do { - { local $@; require Moo::Object; } ('Moo::Object'); + require Moo::Object; ('Moo::Object'); } unless @{"${target}::ISA"}; } } @@ -52,11 +52,8 @@ sub _constructor_maker_for { my ($class, $target, $select_super) = @_; return unless $MAKERS{$target}; $MAKERS{$target}{constructor} ||= do { - { - local $@; - require Method::Generate::Constructor; - require Sub::Defer; - } + require Method::Generate::Constructor; + require Sub::Defer; my ($moo_constructor, $con); if ($select_super && $MAKERS{$select_super}) { @@ -82,7 +79,7 @@ sub _constructor_maker_for { ->new( package => $target, accessor_generator => do { - { local $@; require Method::Generate::Accessor; } + require Method::Generate::Accessor; Method::Generate::Accessor->new; }, construction_string => ( diff --git a/lib/Moo/Role.pm b/lib/Moo/Role.pm index 0484277..5b3761f 100644 --- a/lib/Moo/Role.pm +++ b/lib/Moo/Role.pm @@ -17,7 +17,7 @@ sub import { *{_getglob "${target}::has"} = sub { my ($name, %spec) = @_; ($INFO{$target}{accessor_maker} ||= do { - { local $@; require Method::Generate::Accessor; } + require Method::Generate::Accessor; Method::Generate::Accessor->new })->generate_method($target, $name, \%spec); $INFO{$target}{attributes}{$name} = \%spec; @@ -40,7 +40,7 @@ sub create_class_with_roles { return $new_name if $Role::Tiny::COMPOSED{class}{$new_name}; - { local $@; require Sub::Quote; } + require Sub::Quote; $me->SUPER::create_class_with_roles($superclass, @roles); diff --git a/lib/Moo/_Utils.pm b/lib/Moo/_Utils.pm index 2ee545c..5f5e51f 100644 --- a/lib/Moo/_Utils.pm +++ b/lib/Moo/_Utils.pm @@ -40,7 +40,7 @@ sub _load_module { # can't just ->can('can') because a sub-package Foo::Bar::Baz # creates a 'Baz::' key in Foo::Bar's symbol table return 1 if grep !/::$/, keys %{_getstash($_[0])||{}}; - { local $@; require "${proto}.pm"; } + { require "${proto}.pm"; } return 1; } diff --git a/lib/Role/Tiny.pm b/lib/Role/Tiny.pm index 4479012..6af899f 100644 --- a/lib/Role/Tiny.pm +++ b/lib/Role/Tiny.pm @@ -53,7 +53,7 @@ sub import { # inflate constant subs into real subs) - also add '' to here (this # is used later) @{$INFO{$target}{not_methods}={}}{ - '', map { *$_{CODE}||() } grep !_is_scalar_ref($_), values %$stash + '', map { *$_{CODE}||() } grep !ref($_), values %$stash } = (); # a role does itself $APPLIED_TO{$target} = { $target => undef }; @@ -182,7 +182,7 @@ sub _concrete_methods_of { my $code = *{$stash->{$_}}{CODE}; # rely on the '' key we added in import for "no code here" exists $not_methods->{$code||''} ? () : ($_ => $code) - } grep !_is_scalar_ref($stash->{$_}), keys %$stash + } grep !ref($stash->{$_}), keys %$stash }; }; } @@ -206,7 +206,7 @@ sub _install_methods { # determine already extant methods of target my %has_methods; @has_methods{grep - +(_is_scalar_ref($stash->{$_}) || *{$stash->{$_}}{CODE}), + +(ref($stash->{$_}) || *{$stash->{$_}}{CODE}), keys %$stash } = ();