b8c914
From b3937e202aaf10c2f8996e2993c880bb38a7a268 Mon Sep 17 00:00:00 2001
b8c914
From: Father Chrysostomos <sprout@cpan.org>
b8c914
Date: Wed, 1 Nov 2017 13:11:27 -0700
b8c914
Subject: [PATCH] =?UTF-8?q?Carp:=20Don=E2=80=99t=20choke=20on=20ISA=20cons?=
b8c914
 =?UTF-8?q?tant?=
b8c914
MIME-Version: 1.0
b8c914
Content-Type: text/plain; charset=UTF-8
b8c914
Content-Transfer-Encoding: 8bit
b8c914
b8c914
This broke some time between 1.29 (perl 5.18) and 1.3301 (perl 5.20):
b8c914
b8c914
$ perl5.20.1 -e 'package Foo { use constant ISA => 42; Bar::f() } package Bar { use Carp; sub f { carp "tun syn" } }'
b8c914
Not a GLOB reference at /usr/local/lib/perl5/5.20.1/Carp.pm line 560.
b8c914
b8c914
and still persisted in bleadperl (Carp 1.43) until this commit.
b8c914
b8c914
The code that goes poking through the symbol table needs to take into
b8c914
account that not all stash elements are globs.
b8c914
b8c914
Signed-off-by: Petr Písař <ppisar@redhat.com>
b8c914
---
b8c914
 dist/Carp/lib/Carp.pm |  3 ++-
b8c914
 dist/Carp/t/Carp.t    | 13 ++++++++++++-
b8c914
 2 files changed, 14 insertions(+), 2 deletions(-)
b8c914
b8c914
diff --git a/dist/Carp/lib/Carp.pm b/dist/Carp/lib/Carp.pm
b8c914
index 6127b26f54..ef11a0c046 100644
b8c914
--- a/dist/Carp/lib/Carp.pm
b8c914
+++ b/dist/Carp/lib/Carp.pm
b8c914
@@ -593,7 +593,8 @@ sub trusts_directly {
b8c914
     for my $var (qw/ CARP_NOT ISA /) {
b8c914
         # Don't try using the variable until we know it exists,
b8c914
         # to avoid polluting the caller's namespace.
b8c914
-        if ( $stash->{$var} && *{$stash->{$var}}{ARRAY} && @{$stash->{$var}} ) {
b8c914
+        if ( $stash->{$var} && ref \$stash->{$var} eq 'GLOB'
b8c914
+          && *{$stash->{$var}}{ARRAY} && @{$stash->{$var}} ) {
b8c914
            return @{$stash->{$var}}
b8c914
         }
b8c914
     }
b8c914
diff --git a/dist/Carp/t/Carp.t b/dist/Carp/t/Carp.t
b8c914
index 65daed7c6c..b1e399d143 100644
b8c914
--- a/dist/Carp/t/Carp.t
b8c914
+++ b/dist/Carp/t/Carp.t
b8c914
@@ -3,7 +3,7 @@ no warnings "once";
b8c914
 use Config;
b8c914
 
b8c914
 use IPC::Open3 1.0103 qw(open3);
b8c914
-use Test::More tests => 67;
b8c914
+use Test::More tests => 68;
b8c914
 
b8c914
 sub runperl {
b8c914
     my(%args) = @_;
b8c914
@@ -488,6 +488,17 @@ SKIP:
b8c914
     );
b8c914
 }
b8c914
 
b8c914
+{
b8c914
+    package Mpar;
b8c914
+    sub f { Carp::croak "tun syn" }
b8c914
+
b8c914
+    package Phou;
b8c914
+    $Phou::{ISA} = \42;
b8c914
+    eval { Mpar::f };
b8c914
+}
b8c914
+like $@, qr/tun syn/, 'Carp can handle non-glob ISA stash elems';
b8c914
+
b8c914
+
b8c914
 # New tests go here
b8c914
 
b8c914
 # line 1 "XA"
b8c914
-- 
b8c914
2.13.6
b8c914