From: Gisle Aas Date: Thu, 16 Mar 2006 12:01:10 +0000 (+0000) Subject: require should ignore directories found when searching @INC not just X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6b845e562be40aac749b544b6d494078c54de4aa;p=p5sagit%2Fp5-mst-13.2.git require should ignore directories found when searching @INC not just die as soon as it finds one. It should for instance be possible to for require "File" to read the file "./File" even if there happens to be a "File" directory in perl's standard library. This fixes the RT #24404 fix in change 26373. p4raw-id: //depot/perl@27515 --- diff --git a/pp_ctl.c b/pp_ctl.c index fcc6220..4b0703b 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3011,14 +3011,10 @@ S_check_type_and_open(pTHX_ const char *name, const char *mode) { Stat_t st; const int st_rc = PerlLIO_stat(name, &st); - if (st_rc < 0) { + if (st_rc < 0 || S_ISDIR(st.st_mode) || S_ISBLK(st.st_mode)) { return NULL; } - if(S_ISDIR(st.st_mode) || S_ISBLK(st.st_mode)) { - Perl_die(aTHX_ "%s %s not allowed in require", - S_ISDIR(st.st_mode) ? "Directory" : "Block device", name); - } return PerlIO_open(name, mode); } diff --git a/t/comp/require.t b/t/comp/require.t index 72f11d8..d06834a 100755 --- a/t/comp/require.t +++ b/t/comp/require.t @@ -183,7 +183,7 @@ $foo = eval {require bleah}; delete $INC{"bleah.pm"}; ++$::i; my $r = "threads"; eval { require $r }; $i++; -if($@ =~ /Directory .*threads not allowed in require/) { +if($@ =~ /Can't locate threads in \@INC/) { print "ok $i\n"; } else { print "not ok $i\n";