In perl.git, the branch maint-5.22 has been updated <http://perl5.git.perl.org/perl.git/commitdiff/55acfabdc7e61c9e3607d98a6dbfd77b235c3e73?hp=04f7594e04e0aa46d8b168978ae07a080cb49b47>
- Log ----------------------------------------------------------------- commit 55acfabdc7e61c9e3607d98a6dbfd77b235c3e73 Author: Steve Hay <[email protected]> Date: Wed Aug 10 14:04:23 2016 +0100 Update customized.dat entry for base.pm (This was missed when cherry-picking base.pm changes from blead since it's currently not listed in blead's customized.dat!) M t/porting/customized.dat commit 0aff3358fcfaf0837cce188f04ba6b0444b3a144 Author: Father Chrysostomos <[email protected]> Date: Wed Aug 10 08:21:02 2016 +0100 Add Chris Travers to AUTHORS (cherry picked from commit 5e196316f76f6f3ce68647b65f6a2609b286674b) M AUTHORS commit 6bcd39a65fd349de4dea14c3ff0ab91203000105 Author: Father Chrysostomos <[email protected]> Date: Thu Aug 4 23:23:09 2016 -0700 [perl #128769] Improve base.pm @INC . message The new version is based on one written by Chris Travers, polished up a bit by yours truly. (cherry picked from commit 458470f62360040dcd4b5a55c8ba07503e1af5fc) M dist/base/lib/base.pm M dist/base/t/incdot.t commit cdffa5b319d1b55b87e0e4a32787c1da448d68a3 Author: Father Chrysostomos <[email protected]> Date: Mon Aug 1 21:59:57 2016 -0700 [perl #128769] base.pm: Localize @INC unconditionally As Zefram pointed out in <https://rt.perl.org/Ticket/Display.html?id=128769#txn-1414015>, having inconsistent behaviour is going to cause more problems than solves. (cherry picked from commit 362f3f748cb84934a072fadbfb8b51090e2f9afe) M dist/base/lib/base.pm commit 9189fdaf3f6c98cc9f7e7c18041630ce66d906bb Author: Father Chrysostomos <[email protected]> Date: Wed Aug 10 08:18:57 2016 +0100 MANIFEST typo Sorry for the smoke. (cherry picked from commit ec7784b4e79ac75599f2c7705b9389e05d47d1d1) M MANIFEST commit 37e3ca14ffd858d3892118cd76f2e1e80c767d64 Author: Father Chrysostomos <[email protected]> Date: Wed Aug 10 08:16:49 2016 +0100 [perl #128769] Improve base.pm @INC '.' handling - Localise @INC only if necessary. - Don't mention '.' in the @INC list in the error message, since it was not in the @INC that was searched (this is accomplished by local- ising @INC in the same scope as the error). - If a file exists that would have been loaded had '.' not been ignored, mention it and suggest 'use lib'. - Use the same number of closing as opening parentheses in the error message. (cherry picked from commit bca552795994a553e07b38a6f82a233533919926) M MANIFEST M dist/base/lib/base.pm A dist/base/t/incdot.t ----------------------------------------------------------------------- Summary of changes: AUTHORS | 1 + MANIFEST | 1 + dist/base/lib/base.pm | 19 ++++++++++++++++--- dist/base/t/incdot.t | 19 +++++++++++++++++++ t/porting/customized.dat | 2 +- 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 dist/base/t/incdot.t diff --git a/AUTHORS b/AUTHORS index 3380dae..3dce08e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -230,6 +230,7 @@ Chris Heath <[email protected]> Chris Lightfoot <[email protected]> Chris Nandor <[email protected]> Chris Pepper +Chris Travers <[email protected]> Chris Tubutis <[email protected]> Chris Wick <[email protected]> Chris Williams <[email protected]> diff --git a/MANIFEST b/MANIFEST index a8d6854..955cfd6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2892,6 +2892,7 @@ 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 dist/base/t/fields.t See if fields work +dist/base/t/incdot.t Test how base.pm handles '.' in @INC dist/base/t/isa.t See if base's behaviour doesn't change dist/base/t/lib/Broken.pm Test module for base.pm dist/base/t/lib/Dummy.pm Test module for base.pm diff --git a/dist/base/lib/base.pm b/dist/base/lib/base.pm index ff1a16c..1aa814b 100644 --- a/dist/base/lib/base.pm +++ b/dist/base/lib/base.pm @@ -96,9 +96,9 @@ sub import { { local $SIG{__DIE__}; my $fn = _module_to_filename($base); + local @INC = @INC; + pop @INC if my $dotty = $INC[-1] eq '.'; eval { - local @INC = @INC; - pop @INC if $INC[-1] eq '.'; require $fn }; # Only ignore "Can't locate" errors from our eval require. @@ -114,11 +114,24 @@ sub import { unless (%{"$base\::"}) { require Carp; local $" = " "; - Carp::croak(<<ERROR); + my $e = <<ERROR; Base class package "$base" is empty. (Perhaps you need to 'use' the module which defines that package first, or make that module available in \@INC (\@INC contains: @INC). ERROR + if ($dotty && -e $fn) { + $e .= <<ERROS; + The file $fn does exist in the current directory. But note + that base.pm, when loading a module, now ignores the current working + directory if it is the last entry in \@INC. If your software worked on + previous versions of Perl, the best solution is to use FindBin to + detect the path properly and to add that path to \@INC. As a last + resort, you can re-enable looking in the current working directory by + adding "use lib '.'" to your code. +ERROS + } + $e =~ s/\n\z/)\n/; + Carp::croak($e); } $sigdie = $SIG{__DIE__} || undef; } diff --git a/dist/base/t/incdot.t b/dist/base/t/incdot.t new file mode 100644 index 0000000..1619492 --- /dev/null +++ b/dist/base/t/incdot.t @@ -0,0 +1,19 @@ +#!/usr/bin/perl -w + +use strict; + +use base (); + +use Test::More tests => 2; + +if ($INC[-1] ne '.') { push @INC, '.' } + +my $inc = quotemeta "@INC[0..$#INC-1]"; + +eval { 'base'->import("foo") }; +like $@, qr/\@INC contains: $inc\).\)/, + 'Error does not list final dot in @INC (or mention use lib)'; +eval { 'base'->import('t::lib::Dummy') }; +like $@, qr<\@INC contains: $inc\).\n(?x: + ) The file t/lib/Dummy\.pm does exist in the current direct>, + 'special cur dir message for existing files in . that are ignored'; diff --git a/t/porting/customized.dat b/t/porting/customized.dat index ca01243..1059f30 100644 --- a/t/porting/customized.dat +++ b/t/porting/customized.dat @@ -150,7 +150,7 @@ Win32API::File cpan/Win32API-File/Makefile.PL 605d0aee31aebe84a99408f9ab5f644db5 Win32API::File cpan/Win32API-File/t/file.t 124e64aa77e755235eb297644a87fac5388d3d78 Win32API::File cpan/Win32API-File/t/tie.t 712ea7edd0cc805ce1c0b8172c01b03dd19b583d Win32API::File cpan/Win32API-File/typemap 24bff088babeadac0873e8df390d1666d9d9db4a -base dist/base/lib/base.pm 4d288b5b2070ee71585c5b315ba2b0aedd90cc1f +base dist/base/lib/base.pm 6da574d6e0a807f481957817c7680d0cd27832db libnet cpan/libnet/lib/Net/Cmd.pm 4a9f6e4501549a2d7a04fbf5f9e27ab0c00976f2 libnet cpan/libnet/lib/Net/Config.pm dfa96dcd5a459f9f39e5ca513cefc82b8178520f libnet cpan/libnet/lib/Net/Domain.pm 090c8c06e210102dcf25e6820c6b43b5464ec49a -- Perl5 Master Repository
