Skip to content

Commit

Permalink
[perl #121196] only examine the name being included
Browse files Browse the repository at this point in the history
Checking the location called from broke require overrides.
  • Loading branch information
tonycoz committed Feb 21, 2014
1 parent 1cb49f8 commit 257518b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -2903,6 +2903,7 @@ dist/base/t/base-open-chunk.t See if base works
dist/base/t/base-open-line.t See if base works
dist/base/t/base.t See if base works
dist/base/t/compile-time.t See if base works
dist/base/t/core-global.t See if base works around CORE::GLOBAL::require
dist/base/t/fields-5_6_0.t See if fields work
dist/base/t/fields-5_8_0.t See if fields work
dist/base/t/fields-base.t See if fields work
Expand Down
6 changes: 2 additions & 4 deletions dist/base/lib/base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ sub import {
{
local $SIG{__DIE__};
my $fn = _module_to_filename($base);
my $file = __FILE__;
my $line = __LINE__ + 1;
eval { require $fn };
# Only ignore "Can't locate" errors from our eval require.
# Other fatal errors (syntax etc) must be reported.
Expand All @@ -107,8 +105,8 @@ sub import {
# probably be using parent.pm, which doesn't try to
# guess whether require is needed or failed,
# see [perl #118561]
die if $@ && $@ !~ /^Can't locate \Q$fn\E .*? at \Q$file\E line \Q$line\E(?:, <[^>]*> (?:line|chunk) [0-9]+)?\.\n\z/s
|| $@ =~ /Compilation failed in require at \Q$file\E line \Q$line\E(?:, <[^>]*> (?:line|chunk) [0-9]+)?\.\n\z/;
die if $@ && $@ !~ /^Can't locate \Q$fn\E .*? at .* line [0-9]+(?:, <[^>]*> (?:line|chunk) [0-9]+)?\.\n\z/s
|| $@ =~ /Compilation failed in require at .* line [0-9]+(?:, <[^>]*> (?:line|chunk) [0-9]+)?\.\n\z/;
unless (%{"$base\::"}) {
require Carp;
local $" = " ";
Expand Down
20 changes: 20 additions & 0 deletions dist/base/t/core-global.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/perl -w

use strict;
use Test::More tests => 1;

BEGIN { *CORE::GLOBAL::require = sub { require $_[0] }; }

{
# [perl #121196]
{
package RequireOverride;
sub zzz {}
}
ok(eval <<'EOS', "handle require overrides")
package RequireOverrideB;
use base 'RequireOverride';
1
EOS
or diag $@;
}

0 comments on commit 257518b

Please sign in to comment.