Skip Menu |

This queue is for tickets about the Attribute-Util CPAN distribution.

Report information
The Basics
Id: 46403
Status: resolved
Priority: 0/
Queue: Attribute-Util

People
Owner: Nobody in particular
Requestors: binarin [...] binarin.ru
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.04
Fixed in: (no value)



Subject: Attribute::Method - not preserving line number information and sub names
So, for example, Carp::confess() reports '__ANON__' subroutine in stack trace and invalid line number. With simple modifications to this module it can be avoided: 1) Give '-l' flag to B::Deparse constructor 2) Instead of installing eval'ed anonymous sub, named sub must be evaled: Current code: *$sym = eval qq{ package $pkg; $src }; Needed is something like this (and not adding 'sub' in regexp substitution): my $sub_name = *{$sym}{NAME}; eval qq{package $pkg; sub $sub_name $src};
Subject: attribute-method-subname-linenumbers.patch
--- Method.pm-orig 2009-05-27 13:02:11.000000000 +0400 +++ Method.pm 2009-05-27 13:02:34.000000000 +0400 @@ -7,7 +7,7 @@ our $VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /(\d+)/g; -my $dp = B::Deparse->new(); +my $dp = B::Deparse->new('-l'); my %sigil2ref = ( '$' => \undef, '@' => [], @@ -29,13 +29,14 @@ my ( $pkg, $sym, $ref, undef, $args ) = @_; my $src = $dp->coderef2text($ref); if ($args) { - $src =~ s/\{/sub{\nmy \$self = shift; my ($args) = \@_;\n/; + $src =~ s/\{/{\nmy \$self = shift; my ($args) = \@_;\n/; } else { - $src =~ s/\{/sub{\nmy \$self = shift;\n/; + $src =~ s/\{/{\nmy \$self = shift;\n/; } no warnings 'redefine'; - *$sym = eval qq{ package $pkg; $src }; + my $sub_name = *{$sym}{NAME}; + eval qq{ package $pkg; sub $sub_name $src }; } "Rosebud"; # for MARCEL's sake, not 1 -- dankogai
Thanks, patch applied. VERSION++ in progress. Dan the Maintainer Thereof On Wed May 27 05:06:26 2009, http://binarin.ru/ wrote: Show quoted text
> So, for example, Carp::confess() reports '__ANON__' subroutine in stack > trace and invalid line number. > > With simple modifications to this module it can be avoided: > > 1) Give '-l' flag to B::Deparse constructor > > 2) Instead of installing eval'ed anonymous sub, named sub must be evaled: > > Current code: > > *$sym = eval qq{ package $pkg; $src }; > > > Needed is something like this (and not adding 'sub' in regexp substitution): > > my $sub_name = *{$sym}{NAME}; > eval qq{package $pkg; sub $sub_name $src}; >