Make sure to local-ize $@ and $SIG{__DIE__} for each eval, and rethrow
[gitmo/Class-MOP.git] / lib / Class / MOP / Class.pm
index 964e73e..ecfe5b2 100644 (file)
@@ -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;