From: Tomas Doran Date: Mon, 24 Oct 2011 20:12:53 +0000 (-0700) Subject: Bug fix for require dieing as make_immutable doesn't return true. X-Git-Tag: 5.90006~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=f4de8c998c61fd442cb9590a3c052cf41b4c0d67 Bug fix for require dieing as make_immutable doesn't return true. This is due to a core bug in perl where void context gets passed through to make_immutable, which means it returns nothing: perl -e 'require Catalyst::Script::Create;' succeeds perl -e 'sub foo { require Catalyst::Script::Create; } foo()' fails perl -e 'sub foo { @a = require Catalyst::Script::Create; } foo()' succeeds perl -e 'sub foo { $a = require Catalyst::Script::Create; } foo()' succeeds perl -e 'sub foo { require Catalyst::Script::Create; 1 } foo()' succeeds perl -e 'sub foo { require Catalyst::Script::Create } @x = foo()' succeeds perl -e 'sub foo { require Catalyst::Script::Create } $x = foo()' succeeds Perl versions affected: 5.8 and 5.10, others do not have this issue commit 021f53de09926 by Gerard Goossen appears to be the core bugfix The core bug was that that was being overridden by the special handling for return expressions, and the fix is to prevent that overriding. Rruntime correctness depends on GIMME_V being correct for the require op; it's not forced inside pp_require Zefram++ for digging into this and working out what's going on! --- diff --git a/Changes b/Changes index 100f2da..b490655 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,15 @@ # This file documents the revision history for Perl extension Catalyst. + Bug fixes: + - Add '1;' to all classes which were relying on the ->make_immutable + call to return a true value. Due to perl internals bugs in 5.8 and + 5.10 (not present in other perl versions) require can pass the + context inappropriately, meaning that some methods of loading classes + can fail due to void context being passed throuh to make_immutable, + causing it to not return a value. + This bug is shown by trying to load Catalyst::Script::Create (for example) + with Module::Require and is fixed in core by commit 021f53de09926 + 5.90005 - 2011-10-22 13:35:00 New features: diff --git a/lib/Catalyst/DispatchType/Chained.pm b/lib/Catalyst/DispatchType/Chained.pm index 9c32258..2437698 100644 --- a/lib/Catalyst/DispatchType/Chained.pm +++ b/lib/Catalyst/DispatchType/Chained.pm @@ -404,6 +404,7 @@ sub expand_action { } __PACKAGE__->meta->make_immutable; +1; =head1 USAGE diff --git a/lib/Catalyst/Script/CGI.pm b/lib/Catalyst/Script/CGI.pm index 3a9f449..e05fffb 100644 --- a/lib/Catalyst/Script/CGI.pm +++ b/lib/Catalyst/Script/CGI.pm @@ -7,6 +7,7 @@ sub _plack_engine_name { 'CGI' } with 'Catalyst::ScriptRole'; __PACKAGE__->meta->make_immutable; +1; =head1 NAME diff --git a/lib/Catalyst/Script/Create.pm b/lib/Catalyst/Script/Create.pm index 721c192..529b8c6 100644 --- a/lib/Catalyst/Script/Create.pm +++ b/lib/Catalyst/Script/Create.pm @@ -51,6 +51,7 @@ sub run { } __PACKAGE__->meta->make_immutable; +1; =head1 NAME diff --git a/lib/Catalyst/Script/FastCGI.pm b/lib/Catalyst/Script/FastCGI.pm index c3d2360..fcc431a 100644 --- a/lib/Catalyst/Script/FastCGI.pm +++ b/lib/Catalyst/Script/FastCGI.pm @@ -121,6 +121,7 @@ sub _application_args { } __PACKAGE__->meta->make_immutable; +1; =head1 NAME diff --git a/lib/Catalyst/Script/Server.pm b/lib/Catalyst/Script/Server.pm index ed8aef0..1f4f80e 100644 --- a/lib/Catalyst/Script/Server.pm +++ b/lib/Catalyst/Script/Server.pm @@ -280,7 +280,6 @@ sub _application_args { } __PACKAGE__->meta->make_immutable; - 1; =head1 NAME diff --git a/lib/Catalyst/Script/Test.pm b/lib/Catalyst/Script/Test.pm index 554026e..4209d62 100644 --- a/lib/Catalyst/Script/Test.pm +++ b/lib/Catalyst/Script/Test.pm @@ -17,6 +17,7 @@ sub run { __PACKAGE__->meta->make_immutable; +1; =head1 NAME diff --git a/lib/Catalyst/ScriptRunner.pm b/lib/Catalyst/ScriptRunner.pm index f652e78..7619e61 100644 --- a/lib/Catalyst/ScriptRunner.pm +++ b/lib/Catalyst/ScriptRunner.pm @@ -48,6 +48,7 @@ sub run { } __PACKAGE__->meta->make_immutable; +1; =head1 NAME