David Dyck <dcd@tc.fluke.com> wrote
> when I pass $1 to a subroutine, the subroutine
> can access the value of the variable, but the
> debugger T command and Carp::carp display
> the argument as undef.
This seems to be a very old bug - perl5.002 has it.
Patch for Carp attached. Also mends another obscure bug - you
must never localise @DB::args; it discombobulates caller().
And a small redundancy removed and several questions answered.
The debugger case will take a little longer to fix. Exactly the same
issue, but *much* messier code.
> Summary of my perl5 (revision 5.0 version 7 subversion 17) configuration:
^^
Eh? What version of Perl is that?
Mike Guy
--- ./lib/Carp/Heavy.pm.orig Tue Jun 19 00:34:31 2001
+++ ./lib/Carp/Heavy.pm Sun Jun 24 15:14:01 2001
@@ -28,8 +28,7 @@
my $sub_name = Carp::get_subname(\%call_info);
if ($call_info{has_args}) {
- # Reuse the @args array to avoid warnings. :-)
- local @args = map {Carp::format_arg($_)} @args;
+ my @args = map {Carp::format_arg($_)} @args;
if ($MaxArgNums and @args > $MaxArgNums) { # More than we want to show?
$#args = $MaxArgNums;
push @args, '...';
@@ -120,7 +119,7 @@
sub longmess_heavy {
- return @_ if ref($_[0]); # WHAT IS THIS FOR???
+ return @_ if ref($_[0]); # don't break references as exceptions
my $i = long_error_loc();
return ret_backtrace($i, @_);
}
@@ -139,19 +138,19 @@
$tid_msg = " thread $tid" if $tid;
}
- if ($err =~ /\n$/) {
+ { if ($err =~ /\n$/) { # extra block to localise $1 etc
$mess = $err;
}
else {
my %i = caller_info($i);
$mess = "$err at $i{file} line $i{line}$tid_msg\n";
- }
+ }}
while (my %i = caller_info(++$i)) {
$mess .= "\t$i{sub_name} called at $i{file} line $i{line}$tid_msg\n";
}
- return $mess || $err;
+ return $mess;
}
sub ret_summary {
@@ -190,7 +189,7 @@
sub shortmess_heavy {
return longmess_heavy(@_) if $Verbose;
- return @_ if ref($_[0]); # WHAT IS THIS FOR???
+ return @_ if ref($_[0]); # don't break references as exceptions
my $i = short_error_loc();
if ($i) {
ret_summary($i, @_);
End of patch
Thread Previous
|
Thread Next