Skip Menu |

This queue is for tickets about the Class-Trait CPAN distribution.

Report information
The Basics
Id: 23709
Status: resolved
Priority: 0/
Queue: Class-Trait

People
Owner: Nobody in particular
Requestors: drrho [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: (no value)
Fixed in: (no value)



Subject: Incompatible with the Perl Debugger
Using the following program -------------------------------- package T1; use Class::Trait 'base'; sub t1 { return "11"; } 1; my $o = bless {}, 'Whatever'; Class::Trait->apply ($o, 'T1'); warn $o->t1; -------------------------------------- gives correct results (calling t1), while doing this in the debugger will not: -------------------------------------- rho@mando:~/tmp$ perl -d test.pl Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. Class::Trait::CODE(0x846d314)(/usr/share/perl5/Class/Trait.pm:309): 309: initialize() if keys %TRAITS_TO_CHECK; DB<1> r scalar context return from CODE(0x846d314): 0 T1::(test.pl:9): 1; DB<1> n T1::(test.pl:11): my $o = bless {}, 'Whatever'; DB<1> T1::(test.pl:12): Class::Trait->apply ($o, 'T1'); DB<1> T1::(test.pl:13): warn $o->t1; DB<1> Can't locate object method "t1" via package "Whatever::__ANON__::T1_1" at test.pl line 13. at test.pl line 13 Debugged program terminated. ------------------------------------- Might be an issue for some. \rho
From: OVID [...] cpan.org
Hello Rho, This is an unfortunate problem and it's a tough one to puzzle through. I'll try and check on this later when I have a bit more free time (at work right now). Regrettably, it's possibly one of those "unfixable due to deep magic" issues. Cheers, Ovid On Wed Nov 29 22:13:27 2006, DRRHO wrote: Show quoted text
> Using the following program > > -------------------------------- > package T1; > > use Class::Trait 'base'; > > sub t1 { > return "11"; > } > > 1; > > my $o = bless {}, 'Whatever'; > Class::Trait->apply ($o, 'T1'); > warn $o->t1; > -------------------------------------- > > gives correct results (calling t1), while doing this in the > debugger will not: > > -------------------------------------- > rho@mando:~/tmp$ perl -d test.pl > > Loading DB routines from perl5db.pl version 1.28 > Editor support available. > > Enter h or `h h' for help, or `man perldebug' for more help. > > Class::Trait::CODE(0x846d314)(/usr/share/perl5/Class/Trait.pm:309): > 309: initialize() if keys %TRAITS_TO_CHECK; > DB<1> r > scalar context return from CODE(0x846d314): 0 > T1::(test.pl:9): 1; > DB<1> n > T1::(test.pl:11): my $o = bless {}, 'Whatever'; > DB<1> > T1::(test.pl:12): Class::Trait->apply ($o, 'T1'); > DB<1> > T1::(test.pl:13): warn $o->t1; > DB<1> > Can't locate object method "t1" via package "Whatever::__ANON__::T1_1" > at test.pl line 13. > at test.pl line 13 > Debugged program terminated. > > ------------------------------------- > Might be an issue for some. > > \rho
CC: DRRHO [...] cpan.org
Subject: Re: [rt.cpan.org #23709] Incompatible with the Perl Debugger
Date: Fri, 1 Dec 2006 05:51:20 +1000
To: via RT <bug-Class-Trait [...] rt.cpan.org>
From: Robert Barta <rho [...] bigpond.net.au>
On Thu, Nov 30, 2006 at 05:14:18AM -0500, via RT wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=23709 > > > Hello Rho, > > This is an unfortunate problem and it's a tough one to puzzle through. > I'll try and check on this later when I have a bit more free time (at > work right now). Regrettably, it's possibly one of those "unfixable due > to deep magic" issues.
The missing debugger tolerability is mayby painful, but not a showstopper. But it also affects the profiler. The good news is that the problem will go away with Perl6 :-] Maybe a NOTE in the documentation to warn people is appropriate? \rho
I'm willing to bet its the lvalue accessors of Class::Trait::Config.
Subject: [PATCH] Incompatible with the Perl Debugger
Setting an lvalue accessor appears to be unreliable in the debugger. To see the explody just run t/010_class_trait.t in the debugger. Dumping out $trait_config just before its passed into _get_trait_requirements() in _load_trait() shows the preceding setting of $trait_config->name did not take. The attached patch makes Class::Trait::Config use conventional accessors via Class::Accessor::Fast instead. It now works in the debugger.
---------------------------------------------------------------------- r31152: schwern | 2007-06-12 19:43:58 -0700 lvalue subroutines are experimental and don't seem to work right in the debugger. Get rid of them. ---------------------------------------------------------------------- === local/Class-Trait/t/050_Trait_Config_test.t ================================================================== --- local/Class-Trait/t/050_Trait_Config_test.t (revision 31151) +++ local/Class-Trait/t/050_Trait_Config_test.t (revision 31152) @@ -55,12 +55,12 @@ # add in those same variables -$trait_config->name = $name; -$trait_config->sub_traits = $sub_traits; -$trait_config->requirements = $requirements; -$trait_config->methods = $methods; -$trait_config->overloads = $overloads; -$trait_config->conflicts = $conflicts; +$trait_config->name($name); +$trait_config->sub_traits($sub_traits); +$trait_config->requirements($requirements); +$trait_config->methods($methods); +$trait_config->overloads($overloads); +$trait_config->conflicts($conflicts); # now test that they were successfully inserted === local/Class-Trait/lib/Class/Trait/Config.pm ================================================================== --- local/Class-Trait/lib/Class/Trait/Config.pm (revision 31151) +++ local/Class-Trait/lib/Class/Trait/Config.pm (revision 31152) @@ -3,8 +3,10 @@ use strict; use warnings; -our $VERSION = '0.04'; +use base qw(Class::Accessor::Fast); +our $VERSION = '0.04_01'; + # we are going for a very struct-like class here to try and keep the # syntactical noise down. @@ -23,31 +25,10 @@ }, $class; } -# just use basic l-valued methods for clarity and speed. -sub name : lvalue { - $_[0]->{name}; -} +__PACKAGE__->mk_accessors(qw( + name sub_traits requirements methods overloads conflicts +)); -sub sub_traits : lvalue { - $_[0]->{sub_traits}; -} - -sub requirements : lvalue { - $_[0]->{requirements}; -} - -sub methods : lvalue { - $_[0]->{methods}; -} - -sub overloads : lvalue { - $_[0]->{overloads}; -} - -sub conflicts : lvalue { - $_[0]->{conflicts}; -} - # a basic clone function for moving in and out of the cache. sub clone { my $self = shift; @@ -95,34 +76,31 @@ =item B<name> -An C<lvalue> subroutine for accessing the C<name> string field of the -Class::Trait::Config object. +An accessor to the C<name> string field of the Class::Trait::Config object. =item B<sub_traits> -An C<lvalue> subroutine for accessing the C<sub_traits> array reference field -of the Class::Trait::Config object. +An accessor to the C<sub_traits> array reference field of the Class::Trait::Config object. =item B<requirements> -An C<lvalue> subroutine for accessing the C<requirements> hash reference field +An accessor to the C<requirements> hash reference field of the Class::Trait::Config object. Note, the requirements field is a hash reference to speed requirement lookup, the values of the hash are simply booleans. =item B<methods> -An C<lvalue> subroutine for accessing the C<methods> hash reference field of -the Class::Trait::Config object. +An accessor to the C<methods> hash reference field of the Class::Trait::Config object. =item B<overloads> -An C<lvalue> subroutine for accessing the C<overloads> hash reference field of +An accessor to the C<overloads> hash reference field of the Class::Trait::Config object. =item B<conflicts> -An C<lvalue> subroutine for accessing the C<conflicts> hash reference field of +An accessor to the C<conflicts> hash reference field of the Class::Trait::Config object. Note, the conflicts field is a hash reference to speed conflict lookup, the values of the hash are simply booleans. === local/Class-Trait/lib/Class/Trait.pm ================================================================== --- local/Class-Trait/lib/Class/Trait.pm (revision 31151) +++ local/Class-Trait/lib/Class/Trait.pm (revision 31152) @@ -684,7 +684,7 @@ # initialize our trait configuration my $trait_config = Class::Trait::Config->new(); - $trait_config->name = $trait; + $trait_config->name($trait); _get_trait_requirements($trait_config); _get_trait_methods($trait_config); @@ -704,7 +704,7 @@ if (DEBUG) { $debug_indent--; debug "< dumping trait ($trait) with subtraits (" - . ( join ", " => @{ $trait_config->{sub_traits} } ) . ") : " + . ( join ", " => @{ $trait_config->sub_traits } ) . ") : " . Data::Dumper::Dumper($trait_config); } } @@ -737,8 +737,8 @@ # create a new trait config to represent the combined traits my $trait_config = Class::Trait::Config->new(); - $trait_config->name = $overriding_trait->name; - $trait_config->sub_traits = [ + $trait_config->name($overriding_trait->name); + $trait_config->sub_traits([ # if we have a composite trait we dont want to include the name here # as it is actually defined better in the sub_traits field, but if we @@ -746,19 +746,22 @@ ( ( COMPOSITE() eq $trait->name ) ? () : $trait->name ), @{ $trait->sub_traits } - ]; + ]); # let the overriding trait override the methods in the regular trait - $trait_config->methods - = { %{ $trait->methods }, %{ $overriding_trait->methods } }; + $trait_config->methods( + { %{ $trait->methods }, %{ $overriding_trait->methods } } + ); # the same for overloads - $trait_config->overloads - = { %{ $trait->overloads }, %{ $overriding_trait->overloads } }; + $trait_config->overloads( + { %{ $trait->overloads }, %{ $overriding_trait->overloads } } + ); # now combine the requirements as well - $trait_config->requirements - = { %{ $trait->requirements }, %{ $overriding_trait->requirements } }; + $trait_config->requirements( + { %{ $trait->requirements }, %{ $overriding_trait->requirements } } + ); if (DEBUG) { debug "? checking for requirement fufillment"; @@ -838,7 +841,7 @@ # get any requirements in the trait and turn it into a hash so we can # track stuff easier - $trait_config->requirements = { map { $_ => 1 } @{"${trait}::REQUIRES"} } + $trait_config->requirements({ map { $_ => 1 } @{"${trait}::REQUIRES"} }) if defined @{"${trait}::"}{REQUIRES}; } @@ -867,7 +870,7 @@ } $implementation_for{$_} = $method; } - $trait_config->methods = \%implementation_for; + $trait_config->methods(\%implementation_for); } sub _get_trait_overloads { @@ -884,7 +887,7 @@ debug "< getting overloads for ${trait}" if DEBUG; # get the overload parameter hash - $trait_config->overloads = { %{"${trait}::OVERLOADS"} } + $trait_config->overloads({ %{"${trait}::OVERLOADS"} }) if defined %{"${trait}::OVERLOADS"}; } @@ -1012,7 +1015,7 @@ my $trait_config = Class::Trait::Config->new(); # we are making a composite trait, so lets call it as such - $trait_config->name = COMPOSITE; + $trait_config->name(COMPOSITE); $debug_indent++ if DEBUG; === local/Class-Trait/Build.PL ================================================================== --- local/Class-Trait/Build.PL (revision 31151) +++ local/Class-Trait/Build.PL (revision 31152) @@ -8,9 +8,10 @@ dist_author => 'Curtis "Ovid" Poe <ovid@cpan.org>', dist_version_from => 'lib/Class/Trait.pm', requires => { - 'Test::Differences' => 0.47, - 'Test::Simple' => 0.62, - 'File::Spec' => 0, + 'Test::Differences' => 0.47, + 'Test::Simple' => 0.62, + 'File::Spec' => 0, + 'Class::Accessor::Fast' => 0, }, add_to_cleanup => ['Class-Trait-*'], create_makefile_pl => 'traditional',
CC: DRRHO [...] cpan.org
Subject: Re: [rt.cpan.org #23709] [PATCH] Incompatible with the Perl Debugger
Date: Wed, 13 Jun 2007 09:54:44 +0200
To: Michael G Schwern via RT <bug-Class-Trait [...] rt.cpan.org>
From: Robert Barta <rho [...] devc.at>
On Tue, Jun 12, 2007 at 10:51:47PM -0400, Michael G Schwern via RT wrote: Show quoted text
Show quoted text
> The attached patch makes Class::Trait::Config use conventional accessors > via Class::Accessor::Fast instead. It now works in the debugger.
Confirmed, thx. Will this patch go (soon) into a new CPAN version? \rho
From: OVID [...] cpan.org
On Wed Jun 13 03:58:07 2007, rho@devc.at wrote: Show quoted text
> On Tue, Jun 12, 2007 at 10:51:47PM -0400, Michael G Schwern via RT wrote: >
> > The attached patch makes Class::Trait::Config use conventional accessors > > via Class::Accessor::Fast instead. It now works in the debugger.
> > Confirmed, thx. Will this patch go (soon) into a new CPAN version? > > \rho
I don't have the time to test this at the moment, but assuming it works, I'll ensure that this patch, or a variation of it, will be in the next release. Cheers, Ovid
This has been fixed in 0.31, which I've just uploaded. As this module is deprecated, I don't anticipate more bugfixes. Cheers, Ovid