From bf4588d0c394f60786161c36506f799e7007b077 Mon Sep 17 00:00:00 2001 From: Zefram Date: Thu, 22 Aug 2013 22:57:01 +0100 Subject: [PATCH] detect Carp/Carp::Heavy version mismatch [rt.cpan.org #79649] If an old Carp, requiring old-style Carp::Heavy that provides subroutines, gets a newer stub-style Carp::Heavy, due to @INC having changed, the resulting error messages were not awesome. --- MANIFEST | 1 + dist/Carp/lib/Carp/Heavy.pm | 5 +++++ dist/Carp/t/heavy_mismatch.t | 8 ++++++++ pod/perldelta.pod | 5 ++++- 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 dist/Carp/t/heavy_mismatch.t diff --git a/MANIFEST b/MANIFEST index cad6c18..b11bee4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2986,6 +2986,7 @@ dist/Carp/t/baduni.t See if Carp handles non-char Unicode dist/Carp/t/baduni_warnings.t See if Carp handles non-char Unicode when loaded via warnings.pm dist/Carp/t/Carp_overload.t See if Carp handles overloads dist/Carp/t/Carp.t See if Carp works +dist/Carp/t/heavy_mismatch.t See if Carp::Heavy catches version mismatch dist/Carp/t/heavy.t See if Carp::Heavy works dist/Carp/t/stash_deletion.t See if Carp handles stash deletion dist/Carp/t/swash.t See if Carp avoids breaking swash loading diff --git a/dist/Carp/lib/Carp/Heavy.pm b/dist/Carp/lib/Carp/Heavy.pm index f0de263..f8c409e 100644 --- a/dist/Carp/lib/Carp/Heavy.pm +++ b/dist/Carp/lib/Carp/Heavy.pm @@ -4,6 +4,11 @@ use Carp (); our $VERSION = '1.32'; +my $cv = defined($Carp::VERSION) ? $Carp::VERSION : "undef"; +if($cv ne $VERSION) { + die "Version mismatch between Carp $cv ($INC{q(Carp.pm)}) and Carp::Heavy $VERSION ($INC{q(Carp/Heavy.pm)}). Did you alter \@INC after Carp was loaded?\n"; +} + 1; # Most of the machinery of Carp used to be here. diff --git a/dist/Carp/t/heavy_mismatch.t b/dist/Carp/t/heavy_mismatch.t new file mode 100644 index 0000000..233bc5a --- /dev/null +++ b/dist/Carp/t/heavy_mismatch.t @@ -0,0 +1,8 @@ +print "1..1\n"; + +$INC{"Carp.pm"} = ""; +$Carp::VERSION = "0.90"; +eval { require Carp::Heavy; }; +print $@ =~ /\AVersion mismatch between Carp 0\.90 \(\) and Carp::Heavy [0-9._]+ \(.+\)\. Did you alter \@INC after Carp was loaded\?\n/ ? "" : "not ", "ok 1\n"; + +1; diff --git a/pod/perldelta.pod b/pod/perldelta.pod index cc9ba6d..2a5fd5f 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -121,10 +121,13 @@ XXX L has been upgraded from version 1.31 to 1.32. -Carp now won't vivify the C glob or subroutine or the +C now won't vivify the C glob or subroutine or the C stash. It also avoids some unwanted Unicode warnings on older Perls (which doesn't affect behaviour with current Perl). +C detects version mismatch with C, to give a good +error message if a current (stub) C gets loaded by an old +C that expects C to provide subroutines. =item * -- 2.7.4