projects
/
gitmo/Mouse.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
(parent:
9ae9702
)
Add localization of $@ and $? in DESTROY
gfx [Sat, 10 Oct 2009 08:57:45 +0000 (17:57 +0900)]
lib/Mouse/Meta/Method/Destructor.pm
patch
|
blob
|
blame
|
history
lib/Mouse/Object.pm
patch
|
blob
|
blame
|
history
diff --git
a/lib/Mouse/Meta/Method/Destructor.pm
b/lib/Mouse/Meta/Method/Destructor.pm
index
66f4709
..
28e260f
100644
(file)
--- a/
lib/Mouse/Meta/Method/Destructor.pm
+++ b/
lib/Mouse/Meta/Method/Destructor.pm
@@
-21,7
+21,17
@@
sub _generate_destructor{
my $source = sprintf("#line %d %s\n", __LINE__, __FILE__) . <<"...";
sub {
my \$self = shift;
- $demolishall;
+ local \$?;
+
+ my \$e = do{
+ local \$@;
+ eval{
+ $demolishall;
+ };
+ \$@;
+ };
+ no warnings 'misc';
+ die \$e if \$e; # rethrow
}
...
diff --git
a/lib/Mouse/Object.pm
b/lib/Mouse/Object.pm
index
127a575
..
60f6aad
100644
(file)
--- a/
lib/Mouse/Object.pm
+++ b/
lib/Mouse/Object.pm
@@
-30,7
+30,18
@@
sub BUILDARGS {
sub DESTROY {
my $self = shift;
- $self->DEMOLISHALL();
+ local $?;
+
+ my $e = do{
+ local $@;
+ eval{
+ $self->DEMOLISHALL();
+ };
+ $@;
+ };
+
+ no warnings 'misc';
+ die $e if $e; # rethrow
}
sub BUILDALL {