This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Carp was mostly unusable with Safe because it may require
[perl5.git] / lib / Carp.pm
index 5dbae29..b09efd4 100644 (file)
@@ -1,6 +1,6 @@
 package Carp;
 
-our $VERSION = '1.01';
+our $VERSION = '1.02';
 
 =head1 NAME
 
@@ -119,6 +119,7 @@ call die() or warn(), as appropriate.
 # text and function arguments should be formatted when printed.
 
 $CarpInternal{Carp}++;
+$CarpInternal{warnings}++;
 $CarpLevel = 0;                # How many extra package levels to skip on carp.
                         # How many calls to skip on confess.
                         # Reconciling these notions is hard, use
@@ -154,7 +155,12 @@ sub export_fail {
 # each function call on the stack.
 
 sub longmess {
-    { local $@; require Carp::Heavy; } # XXX fix require to not clear $@?
+    {
+       local $@;
+       # XXX fix require to not clear $@?
+       # don't use require unless we need to (for Safe compartments)
+       require Carp::Heavy unless $INC{"Carp/Heavy.pm"};
+    }
     # Icky backwards compatibility wrapper. :-(
     my $call_pack = caller();
     if ($Internal{$call_pack} or $CarpInternal{$call_pack}) {
@@ -174,7 +180,12 @@ sub longmess {
 # you always get a stack trace
 
 sub shortmess {        # Short-circuit &longmess if called via multiple packages
-    { local $@; require Carp::Heavy; } # XXX fix require to not clear $@?
+    {
+       local $@;
+       # XXX fix require to not clear $@?
+       # don't use require unless we need to (for Safe compartments)
+       require Carp::Heavy unless $INC{"Carp/Heavy.pm"};
+    }
     # Icky backwards compatibility wrapper. :-(
     my $call_pack = caller();
     local @CARP_NOT = caller();