Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 447d435

Browse files
author
Reini Urban
committed
base: Update to 2.23_01
fixes for missing . in @inc (cperl or -Dfortify_inc).
1 parent 257e402 commit 447d435

File tree

10 files changed

+100
-5
lines changed

10 files changed

+100
-5
lines changed

MANIFEST

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,7 +3293,11 @@ dist/base/t/fields-5_6_0.t See if fields work
32933293
dist/base/t/fields-5_8_0.t See if fields work
32943294
dist/base/t/fields-base.t See if fields work
32953295
dist/base/t/fields.t See if fields work
3296+
dist/base/t/incdot.t See if base works
3297+
dist/base/t/incmodified-vs-incdot.t See if base works
32963298
dist/base/t/isa.t See if base's behaviour doesn't change
3299+
dist/base/t/lib/BaseIncExtender.pm Test module for base.pm
3300+
dist/base/t/lib/BaseIncDoubleExtender.pm Test module for base.pm
32973301
dist/base/t/lib/Broken.pm Test module for base.pm
32983302
dist/base/t/lib/Dummy.pm Test module for base.pm
32993303
dist/base/t/lib/HasSigDie.pm Module for testing base.pm

Porting/Maintainers.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ package Maintainers;
236236
'base' => {
237237
'DISTRIBUTION' => 'RJBS/base-2.23.tar.gz',
238238
'FILES' => q[dist/base],
239+
'CUSTOMIZED' => [ qw[ lib/base.pm ] ],
239240
},
240241

241242
'bignum' => {

dist/Module-CoreList/lib/Module/CoreList.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13280,6 +13280,7 @@ for my $version ( sort { version_sort($a, $b) } keys %released ) {
1328013280
'Socket' => '2.024_02',
1328113281
'YAML::XS' => '0.71',
1328213282
'YAML::LibYAML' => '0.71',
13283+
'base' => '2.23_01'
1328313284
},
1328413285
removed => {
1328513286
}

dist/base/Changes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
2.23
2-
- no changes since 2.23
2+
- no changes since 2.22_01
33

44
2.22_01
55
- require perl v5.8.0; tests for [perl #121196] break on 5.6.1, and

dist/base/lib/base.pm

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ package base;
33

44
use strict 'vars';
55
use vars qw($VERSION);
6-
$VERSION = '2.23';
6+
$VERSION = '2.23_01';
77
$VERSION =~ tr/_//d;
88

9+
# simplest way to avoid indexing of the package: no package statement
10+
sub base::__inc_scope_guard::DESTROY {
11+
my $noop = $_[0][0];
12+
ref $_ and $_ == $noop and $_ = '.' for @INC;
13+
}
14+
915
# constant.pm is slow
1016
sub SUCCESS () { 1 }
1117

@@ -91,13 +97,17 @@ sub import {
9197

9298
next if grep $_->isa($base), ($inheritor, @bases);
9399

94-
# Following blocks help isolate $SIG{__DIE__} changes
100+
# Following blocks help isolate $SIG{__DIE__} and @INC changes
95101
{
96102
my $sigdie;
97103
{
98104
local $SIG{__DIE__};
99105
my $fn = _module_to_filename($base);
100-
eval { require $fn };
106+
my $dotty = $INC[-1] eq '.' && ( $INC[-1] = sub {()} );
107+
eval {
108+
my $redotty = $dotty && bless [ $dotty ], 'base::__inc_scope_guard';
109+
require $fn
110+
};
101111
# Only ignore "Can't locate" errors from our eval require.
102112
# Other fatal errors (syntax etc) must be reported.
103113
#
@@ -111,11 +121,24 @@ sub import {
111121
unless (%{"$base\::"}) {
112122
require Carp;
113123
local $" = " ";
114-
Carp::croak(<<ERROR);
124+
my $e = <<ERROR;
115125
Base class package "$base" is empty.
116126
(Perhaps you need to 'use' the module which defines that package first,
117127
or make that module available in \@INC (\@INC contains: @INC).
118128
ERROR
129+
if ($dotty && -e $fn) {
130+
$e .= <<ERROS;
131+
The file $fn does exist in the current directory. But note
132+
that base.pm, when loading a module, now ignores the current working
133+
directory if it is the last entry in \@INC. If your software worked on
134+
previous versions of Perl, the best solution is to use FindBin to
135+
detect the path properly and to add that path to \@INC. As a last
136+
resort, you can re-enable looking in the current working directory by
137+
adding "use lib '.'" to your code.
138+
ERROS
139+
}
140+
$e =~ s/\n\z/)\n/;
141+
Carp::croak($e);
119142
}
120143
$sigdie = $SIG{__DIE__} || undef;
121144
}

dist/base/t/incdot.t

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/perl -w
2+
3+
use strict;
4+
5+
use base ();
6+
7+
use Test::More tests => 2;
8+
9+
if ($INC[-1] ne '.') { push @INC, '.' }
10+
11+
my $inc = quotemeta "@INC";
12+
13+
eval { 'base'->import("foo") };
14+
like $@, qr/\@INC contains: $inc\).\)/,
15+
'Error does not list final dot in @INC (or mention use lib)';
16+
eval { 'base'->import('t::lib::Dummy') };
17+
like $@, qr<\@INC contains: $inc\).\n(?x:
18+
) The file t/lib/Dummy\.pm does exist in the current direct>,
19+
'special cur dir message for existing files in . that are ignored';
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/perl -w
2+
3+
use strict;
4+
use Test::More tests => 10; # one test is in each BaseInc* itself
5+
6+
use lib 't/lib';
7+
8+
# make it look like an older perl
9+
BEGIN { push @INC, '.' if $INC[-1] ne '.' }
10+
11+
use base 'BaseIncExtender';
12+
13+
BEGIN {
14+
is $INC[0], 't/lib/blahblah', 'modules loaded by base can prepend entries to @INC';
15+
is $INC[1], 't/lib', 'previously prepended additional @INC entry remains';
16+
is $INC[-1], '.', 'dot still at end @INC after using base';
17+
}
18+
19+
use base 'BaseIncDoubleExtender';
20+
21+
BEGIN {
22+
is $INC[0], 't/lib/blahdeblah', 'modules loaded by base can prepend entries to @INC';
23+
is $INC[1], 't/lib/blahblah', 'previously prepended additional @INC entry remains';
24+
is $INC[2], 't/lib', 'previously prepended additional @INC entry remains';
25+
is $INC[-2], '.', 'dot still at previous end of @INC after using base';
26+
is $INC[-1], 't/lib/on-end', 'modules loaded by base can append entries to @INC';
27+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package BaseIncDoubleExtender;
2+
3+
BEGIN { ::ok( $INC[-1] ne '.', 'no trailing dot in @INC during module load from base' ) }
4+
5+
use lib 't/lib/blahdeblah';
6+
7+
push @INC, 't/lib/on-end';
8+
9+
1;

dist/base/t/lib/BaseIncExtender.pm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package BaseIncExtender;
2+
3+
BEGIN { ::ok( $INC[-1] ne '.', 'no trailing dot in @INC during module load from base' ) }
4+
5+
use lib 't/lib/blahblah';
6+
7+
1;

pod/perlcdelta.pod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ Change $sv->EXTFLAGS to compflags since 5.22 for CALLREGCOMP().
237237
Turn off MGf_REFCOUNTED.
238238
global-buffer-overflow with dynamic COW strings, wrong savepvn args.
239239

240+
=item base 2.23_01
241+
242+
fixes for missing . in @INC (cperl or -Dfortify_inc).
243+
240244
=back
241245

242246
=head1 Documentation

0 commit comments

Comments
 (0)