From: Dave Rolsky Date: Sun, 21 Jun 2009 15:57:49 +0000 (-0500) Subject: Make sure to local-ize $@ and $SIG{__DIE__} for each eval, and rethrow X-Git-Tag: 0.87~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e4da508a1801f8bf4164d9f5ecbaf96cb343e5aa;p=gitmo%2FClass-MOP.git Make sure to local-ize $@ and $SIG{__DIE__} for each eval, and rethrow $@ as needed. --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 964e73e..ecfe5b2 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -855,7 +855,12 @@ sub add_attribute { $self->get_attribute_map->{$attribute->name} = $attribute; # invalidate package flag here - my $e = do { local $@; eval { $attribute->install_accessors() }; $@ }; + my $e = do { + local $@; + local $SIG{__DIE__}; + eval { $attribute->install_accessors() }; + $@; + }; if ( $e ) { $self->remove_attribute($attribute->name); die $e; diff --git a/lib/Class/MOP/Module.pm b/lib/Class/MOP/Module.pm index ffd6721..6d0f785 100644 --- a/lib/Class/MOP/Module.pm +++ b/lib/Class/MOP/Module.pm @@ -50,8 +50,13 @@ sub _instantiate_module { $code .= "\$$package_name\:\:AUTHORITY = '" . $authority . "';" if defined $authority; - eval $code; - confess "creation of $package_name failed : $@" if $@; + my $e = do { + local $@; + local $SIG{__DIE__}; + eval $code; + $@; + }; + confess "creation of $package_name failed : $e" if $e; } 1;