[Bast-commits] r9839 - in Class-C3-Componentised/trunk: .
lib/Class/C3 t t/lib
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Sat Mar 19 23:55:56 GMT 2011
Author: ribasushi
Date: 2011-03-19 23:55:56 +0000 (Sat, 19 Mar 2011)
New Revision: 9839
Added:
Class-C3-Componentised/trunk/t/03-unstable_dollar_underscore.t
Class-C3-Componentised/trunk/t/lib/DestroyDollarUnderscore.pm
Modified:
Class-C3-Componentised/trunk/Changes
Class-C3-Componentised/trunk/lib/Class/C3/Componentised.pm
Log:
Preserve $_ (RT#66661)
Modified: Class-C3-Componentised/trunk/Changes
===================================================================
--- Class-C3-Componentised/trunk/Changes 2011-03-19 23:34:35 UTC (rev 9838)
+++ Class-C3-Componentised/trunk/Changes 2011-03-19 23:55:56 UTC (rev 9839)
@@ -2,6 +2,8 @@
Stop importing Carp functions (and thus polluting the inheritor
namespaces)
+ Make sure $_ is properly preserved even if the loaded module
+ is negligent enough to change it (RT#66661)
1.0008 24 Feb 2011
Fix inject_base regression introduced during optimizations in
Modified: Class-C3-Componentised/trunk/lib/Class/C3/Componentised.pm
===================================================================
--- Class-C3-Componentised/trunk/lib/Class/C3/Componentised.pm 2011-03-19 23:34:35 UTC (rev 9838)
+++ Class-C3-Componentised/trunk/lib/Class/C3/Componentised.pm 2011-03-19 23:55:56 UTC (rev 9839)
@@ -142,9 +142,9 @@
return if ( *{"${f_class}::$_"}{CODE} );
}
-
# require always returns true on success
- eval { require($file) } or do {
+ # ill-behaved modules might very well obliterate $_
+ eval { local $_; require($file) } or do {
$@ = "Invalid class name '$f_class'" if $f_class =~ $invalid_class;
Added: Class-C3-Componentised/trunk/t/03-unstable_dollar_underscore.t
===================================================================
--- Class-C3-Componentised/trunk/t/03-unstable_dollar_underscore.t (rev 0)
+++ Class-C3-Componentised/trunk/t/03-unstable_dollar_underscore.t 2011-03-19 23:55:56 UTC (rev 9839)
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+
+use Class::C3::Componentised;
+use Test::More;
+use FindBin;
+
+use lib "$FindBin::Bin/lib";
+
+my @mods = 'DestroyDollarUnderscore';
+
+for (@mods) {
+ Class::C3::Componentised->ensure_class_loaded($_);
+}
+
+is_deeply(\@mods, [ 'DestroyDollarUnderscore' ], '$_ untouched');
+
+done_testing;
Added: Class-C3-Componentised/trunk/t/lib/DestroyDollarUnderscore.pm
===================================================================
--- Class-C3-Componentised/trunk/t/lib/DestroyDollarUnderscore.pm (rev 0)
+++ Class-C3-Componentised/trunk/t/lib/DestroyDollarUnderscore.pm 2011-03-19 23:55:56 UTC (rev 9839)
@@ -0,0 +1,8 @@
+package DestroyDollarUnderscore;
+
+use warnings;
+use strict;
+
+undef ($_);
+
+1;
More information about the Bast-commits
mailing list