From: Stevan Little Date: Sun, 11 May 2008 00:55:37 +0000 (+0000) Subject: 0.44 release X-Git-Tag: 0_55~182 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ca0e380d7e2b356396c0d374f7fce4ec45c25162;p=gitmo%2FMoose.git 0.44 release --- diff --git a/Changes b/Changes index 452a081..a10fbba 100644 --- a/Changes +++ b/Changes @@ -3,13 +3,18 @@ Revision history for Perl extension Moose 0.44 Sat. May 10, 2008 * Moose - made make_immutable warning cluck to - show where the error is + show where the error is (thanks mst) * Moose::Object - BUILDALL and DEMOLISHALL now call ->body when looping through the methods, to avoid the overloaded method call. + - fixed issue where DEMOLISHALL was + eating the $@ values, and so not + working correctly, it still kind of + eats them, but so does vanilla perl + - added tests for this * Moose::Cookbook::Recipe7 - added new recipe for immutable @@ -24,7 +29,7 @@ Revision history for Perl extension Moose and exclusion with Roles (thanks Dave Rolsky) * t/ - - fixed Win32 test failure + - fixed Win32 test failure (thanks spicyjack) 0.43 Wed. April, 30, 2008 * NOTE TO SELF: diff --git a/lib/Moose/Object.pm b/lib/Moose/Object.pm index 6c559fb..1806daa 100644 --- a/lib/Moose/Object.pm +++ b/lib/Moose/Object.pm @@ -54,14 +54,15 @@ sub DESTROY { # extra meta level calls return unless $_[0]->can('DEMOLISH'); # if we have an exception here ... - if (my $e = $@) { + if ($@) { + # localize the $@ ... + local $@; # run DEMOLISHALL ourselves, ... - (shift)->DEMOLISHALL; - # then restore the exception ... - $@ = $e; + $_[0]->DEMOLISHALL; # and return ... return; } + # otherwise it is normal destruction goto &DEMOLISHALL; } diff --git a/t/100_bugs/012_DEMOLISH_eats_mini.t b/t/100_bugs/012_DEMOLISH_eats_mini.t index 81eac60..130e2c0 100644 --- a/t/100_bugs/012_DEMOLISH_eats_mini.t +++ b/t/100_bugs/012_DEMOLISH_eats_mini.t @@ -3,12 +3,11 @@ use strict; use warnings; -use Test::More no_plan => 1; +use Test::More tests => 5; use Test::Exception; BEGIN { use_ok('Moose'); - use_ok('Moose::Util::TypeConstraints'); } { @@ -24,12 +23,31 @@ BEGIN { # if no call to ANY Moose::Object->new was done before. sub DEMOLISH { my ( $self ) = @_; + # ... Moose (kinda) eats exceptions in DESTROY/DEMOLISH"; } } -my $obj = eval { Foo->new; }; -::like( $@, qr/is required/, "... Foo plain" ); -::is( $obj, undef, "... the object is undef" ); +{ + my $obj = eval { Foo->new; }; + ::like( $@, qr/is required/, "... Foo plain" ); + ::is( $obj, undef, "... the object is undef" ); +} + +{ + package Bar; + + sub new { die "Bar died"; } + + sub DESTROY { + die "Vanilla Perl eats exceptions in DESTROY too"; + } +} + +{ + my $obj = eval { Bar->new; }; + ::like( $@, qr/Bar died/, "... Bar plain" ); + ::is( $obj, undef, "... the object is undef" ); +} 1;