Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 1911
Status: resolved
Priority: 0/
Queue: Attribute-Handlers

People
Owner: Nobody in particular
Requestors: adrianh [...] quietstars.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.78
Fixed in: (no value)



Subject: Empty DESTROY causes problems
<p>There is an empty DESTROY subroutine in Attribute::Handlers, which means you can't mix it into a class hierarchy with existing DESTROY methods. All the tests run without it - so I'm guessing it's an oversight?</p> <p>Test file demonstrating the problem attached. Fix is (unless I'm missing something) removal of the DESTROY line.</p>
#! /usr/bin/perl use strict; use warnings; use NEXT; my %Called; { package Base; sub new { bless [], shift}; sub DESTROY { ++$Called{+__PACKAGE__}; $_[0]->NEXT::DESTROY; }; } { package Handler; use base qw(Attribute::Handlers Base); sub DESTROY { ++$Called{+__PACKAGE__}; $_[0]->NEXT::DESTROY; }; } # If we remove the DESTROY everything works # undef *Attribute::Handlers::DESTROY; { my $o = Handler->new; }; use Test::More tests => 3; is scalar(keys %Called), 2, 'two destroy methods called'; is $Called{Base}, 1, 'Base destroy called'; is $Called{Handler}, 1, 'Handler destroy called';
Date: Sun, 05 Jan 2003 08:24:26 +1100
From: Damian Conway <damian [...] conway.org>
To: bug-Attribute-Handlers [...] rt.cpan.org
Subject: Re: [cpan #1911] Empty DESTROY causes problems
RT-Send-Cc:
Show quoted text
> This message about Attribute-Handlers was sent to you by ADIE <ADIE@cpan.org> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=1911 > > > <p>There is an empty DESTROY subroutine in Attribute::Handlers, > which means you can't mix it into a class hierarchy with existing DESTROY methods.
You're not *supposed* to mix it into class hierarchies. That's not how it works. Show quoted text
> All the tests run without it - so I'm guessing it's an oversight?</p>
No. Without it, the AUTOLOAD it installs ina base class of UNIVERSAL (yes, really) would intercept every DESTROY call of any class without an explicit destructor. :-( Damian
[damian@conway.org - Sat Jan 4 16:24:40 2003]: Show quoted text
> No. Without it, the AUTOLOAD it installs ina base class of UNIVERSAL > would intercept every DESTROY call of any class without an explicit > destructor. :-(
Using Attribute::Handlers allows implementation of inside-out objects such that subclasses do not need have to implement DESTROY subroutines. However, this bug precludes doing multiple inheritance in such an environment. This problem could be removed by adding logic to AUTOLOAD to ignore DESTROY calls, namely: sub AUTOLOAD { # Ignore DESTROY calls return if $AUTOLOAD =~ /::DESTROY$/; my ($class) = $AUTOLOAD =~ m/(.*)::/g; $AUTOLOAD =~ m/_ATTR_(.*?)_(.*)/ or croak "Can't locate class method '$AUTOLOAD' via package '$class'"; croak "Attribute handler '$2' doesn't handle $1 attributes"; }
Date: Tue, 20 Sep 2005 14:07:50 +1000
To: bug-Attribute-Handlers [...] rt.cpan.org
Subject: Re: [cpan #1911] Empty DESTROY causes problems
From: Damian Conway <thoughtstream [...] gmail.com>
RT-Send-Cc:
Show quoted text
> > Using Attribute::Handlers allows implementation of inside-out objects > such that subclasses do not need have to implement DESTROY subroutines. > However, this bug precludes doing multiple inheritance in such an > environment. This problem could be removed by adding logic to AUTOLOAD > to ignore DESTROY calls, namely: > > sub AUTOLOAD { > # Ignore DESTROY calls > return if $AUTOLOAD =~ /::DESTROY$/; > > my ($class) = $AUTOLOAD =~ m/(.*)::/g; > $AUTOLOAD =~ m/_ATTR_(.*?)_(.*)/ or > croak "Can't locate class method '$AUTOLOAD' via package '$class'"; > croak "Attribute handler '$2' doesn't handle $1 attributes"; > } >
Ah, yes, I see the problem now. I'll definitely patch it for the next release. Damian
I've applied Jerry's patch to bleadperl as change #29351.
Subject: Re: [rt.cpan.org #1911] Empty DESTROY causes problems
Date: Thu, 23 Nov 2006 10:13:02 +0000
To: bug-Attribute-Handlers [...] rt.cpan.org
From: Adrian Howard <adrianh [...] quietstars.com>
Thanks :-) Adrian On 22 Nov 2006, at 15:20, via RT wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=1911 > > > I've applied Jerry's patch to bleadperl as change #29351. >
Marking the ticket as resolved as the proposed patch was applied by Rafael in bleadperl and there's a new version of Attribute::Handlers on its way to CPAN which was taken from blead.