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