From: Rafael Garcia-Suarez Date: Thu, 3 Jun 2004 09:02:31 +0000 (+0000) Subject: Carp was mostly unusable with Safe because it may require X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b27d38316a3a36f667906a55664842ff93c74154;p=p5sagit%2Fp5-mst-13.2.git Carp was mostly unusable with Safe because it may require Carp::Heavy at run-time (while require() is forbidden.) Have Safe load Carp::Heavy. p4raw-id: //depot/perl@22898 --- diff --git a/ext/Opcode/Safe.pm b/ext/Opcode/Safe.pm index 5036943..0d17d9a 100644 --- a/ext/Opcode/Safe.pm +++ b/ext/Opcode/Safe.pm @@ -3,7 +3,7 @@ package Safe; use 5.003_11; use strict; -$Safe::VERSION = "2.10"; +$Safe::VERSION = "2.10_01"; # *** Don't declare any lexicals above this point *** # @@ -26,6 +26,7 @@ sub lexless_anon_sub { } use Carp; +use Carp::Heavy; use Opcode 1.01, qw( opset opset_to_ops opmask_add diff --git a/lib/Carp.pm b/lib/Carp.pm index 6230bb7..b09efd4 100644 --- a/lib/Carp.pm +++ b/lib/Carp.pm @@ -155,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}) { @@ -175,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();