From: gfx Date: Fri, 10 Sep 2010 04:20:08 +0000 (+0900) Subject: Workaround older perl's bug that caused segv by releasing CVs X-Git-Tag: 0.66~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aa3b1c110ba2bde693d43554dc853696ccd41866;p=gitmo%2FMouse.git Workaround older perl's bug that caused segv by releasing CVs --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index 476d8bf..24a2216 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -377,6 +377,12 @@ sub _install_modifier { }; } + # workaround older Perl's bug that caused segv :( + { + no warnings 'once'; + our $__not_used = \&_install_modifier; # keep the CV not to be released + } + # replace this method itself :) { no warnings 'redefine'; diff --git a/t/001_mouse/069-add-modifier.t b/t/001_mouse/069-add-modifier.t index 2a2462a..1a57606 100644 --- a/t/001_mouse/069-add-modifier.t +++ b/t/001_mouse/069-add-modifier.t @@ -1,10 +1,15 @@ #!perl use strict; use warnings; +use lib 't/lib'; use Test::More; use Test::Exception; +throws_ok { + A->meta->add_around_method_modifier(bar => sub { "baz" }); +} qr/The method 'bar' was not found in the inheritance hierarchy for A/; + { package A; use Mouse; @@ -16,8 +21,4 @@ A->meta->add_around_method_modifier(foo => sub { "bar" }); is(A->foo(), 'bar', 'add_around_modifier'); -throws_ok { - A->meta->add_around_method_modifier(bar => sub { "baz" }); -} qr/The method 'bar' was not found in the inheritance hierarchy for A/; - done_testing;