Subject: | Moose::Object DESTROY should localise more |
Date: | Tue, 28 Jul 2009 15:19:53 +0100 |
To: | bug-Moose [...] rt.cpan.org |
From: | Zefram <zefram [...] fysh.org> |
The DESTROY method in Moose::Object attempts to avoid the problem of
clobbering $@, by localising it. However, there are two problems with
the way it does this. Firstly, it only localises $@ if $@ had a true
value to start with. Clobbering a false $@ is just as much a problem,
so the localisation should be unconditional. Secondly, there are four
other status variables suffering the same problem as $@, which should
therefore also be localised. The resulting DESTROY method would be:
sub DESTROY {
local($., $@, $!, $^E, $?);
$_[0]->DEMOLISHALL(in_global_destruction);
}
-zefram