From: Steffen Müller <0mgwtfbbq@sneakemail.com> Date: Wed, 10 Jan 2007 18:52:23 +0000 (+0100) Subject: AutoLoader fix, part 2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3256a4f81269a0cb31d9dd71cd296e224c40dc32;p=p5sagit%2Fp5-mst-13.2.git AutoLoader fix, part 2 Message-ID: <20070110175148.26694.qmail@lists.develooper.com> p4raw-id: //depot/perl@29750 --- diff --git a/lib/AutoLoader.pm b/lib/AutoLoader.pm index 25b3928..e33a4be 100644 --- a/lib/AutoLoader.pm +++ b/lib/AutoLoader.pm @@ -102,7 +102,7 @@ sub find_filename { # (and failing) to find the 'lib/auto/foo/bar.al' because it # looked for 'lib/lib/auto/foo/bar.al', given @INC = ('lib'). - if (-r $filename) { + if (defined $filename and -r $filename) { unless ($filename =~ m|^/|s) { if ($is_dosish) { unless ($filename =~ m{^([a-z]:)?[\\/]}is) { diff --git a/lib/AutoLoader.t b/lib/AutoLoader.t index da7071b..92d66fa 100755 --- a/lib/AutoLoader.t +++ b/lib/AutoLoader.t @@ -16,7 +16,7 @@ BEGIN unshift @INC, $dir; } -use Test::More tests => 21; +use Test::More tests => 22; # First we must set up some autoloader files my $fulldir = File::Spec->catdir( $dir, 'auto', 'Foo' ); @@ -164,8 +164,21 @@ AutoLoader->unimport(); ::is( Baz->AUTOLOAD(), 'i am here', '... but not non-imported AUTOLOAD()' ); + +package SomeClass; +use AutoLoader 'AUTOLOAD'; +sub new { + bless {} => shift; +} + package main; +$INC{"SomeClass.pm"} = $0; # Prepare possible recursion +{ + my $p = SomeClass->new(); +} # <-- deep recursion in AUTOLOAD looking for SomeClass::DESTROY? +::ok(1, "AutoLoader shouldn't loop forever if \%INC is modified"); + # cleanup END { return unless $dir && -d $dir;