In perl.git, the branch maint-5.24 has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/864470e44daa6deaeb9457a408563146daffffca?hp=c1ccc6206280c3a32819220a079405239892de6c>

- Log -----------------------------------------------------------------
commit 864470e44daa6deaeb9457a408563146daffffca
Author: Steve Hay <[email protected]>
Date:   Wed Aug 10 14:05:12 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 1aba563afe52e6e8f466ea92dea1204187097454
Author: Father Chrysostomos <[email protected]>
Date:   Wed Aug 10 08:25:13 2016 +0100

    Add Chris Travers to AUTHORS
    
    (cherry picked from commit 5e196316f76f6f3ce68647b65f6a2609b286674b)

M       AUTHORS

commit af7067bc21e7265a4d0571e7336105a419dbba68
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 86fb43615de97f2306bc6d45c9d2f8e64a8ab889
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 b9a61d80c009283a88b15e961446ae9e218bdf1c
Author: Father Chrysostomos <[email protected]>
Date:   Wed Aug 10 08:24:24 2016 +0100

    MANIFEST typo
    
    Sorry for the smoke.
    
    (cherry picked from commit ec7784b4e79ac75599f2c7705b9389e05d47d1d1)

M       MANIFEST

commit ccbde4774902e879db48b4b02c8d802e66c3547a
Author: Father Chrysostomos <[email protected]>
Date:   Wed Aug 10 08:23:38 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 3cc2ef1..e77fc36 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -233,6 +233,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 e4331f1..e6a3dd9 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -3007,6 +3007,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 b390529..b69f359 100644
--- a/dist/base/lib/base.pm
+++ b/dist/base/lib/base.pm
@@ -97,9 +97,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.
@@ -115,11 +115,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 139acd0..2532e30 100644
--- a/t/porting/customized.dat
+++ b/t/porting/customized.dat
@@ -159,7 +159,7 @@ Test::Harness 
cpan/Test-Harness/lib/TAP/Parser/YAMLish/Reader.pm 76771092dd2b87a
 Test::Harness cpan/Test-Harness/lib/TAP/Parser/YAMLish/Writer.pm 
bf1fbfff9720330886651f183959a5db56daeea0
 Test::Harness cpan/Test-Harness/lib/Test/Harness.pm 
da2d76ba673372da129060c9d0adb8cf0d91f9f7
 autodie cpan/autodie/t/mkdir.t 9e70d2282a3cc7d76a78bf8144fccba20fb37dac
-base dist/base/lib/base.pm ad7566316689227a8050ee255215b268128515fb
+base dist/base/lib/base.pm e46ed81849982613d87463879da4edf4de20ad7e
 bignum cpan/bignum/lib/bigint.pm 56330354995409dab5073ea92d749f8727e265db
 bignum cpan/bignum/lib/bignum.pm e999973f78e6be12282c11bb6328246b31a9576b
 bignum cpan/bignum/lib/bigrat.pm 7fccc9df30e43dbbae6e5ea91b26c8046545c9a9

--
Perl5 Master Repository

Reply via email to