New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attribute::Handlers will trash UNIVERSAL #6873
Comments
From Michael.Jacob@SCHERING.DECreated by micaja@de.ibm.comAttribute::Handlers will trash UNIVERSAL with: push @UNIVERSAL::ISA, 'Attribute::Handlers' this will make all modules fail that trust in if ( $object->can('abc') or $object->can('AUTOLOAD') ) { e.g. XML::SAX, DBI, ... Things like 'AUTOLOAD', 'import', 'DESTROY' or such Suggestion: Override UNIVERSAL::can to reject inherited my $realcan = \&UNIVERSAL::can; Testcase: use CANTEST; PS: I hope I was faster than any time machines this time... Perl Info
|
From Michael.Jacob@SCHERING.DEOops, my suggested code was buggy. I think I had some recursion in mind... Corrected: my $realcan = \&UNIVERSAL::can; * Shortcut for lookups in the "parent of UNIVERSAL" module mmmh. This would even be safer: my $realcan = \&UNIVERSAL::can; * real can() is right if UNIVERSAL can()not. With cache: my $realcan = \&UNIVERSAL::can; |
From @schwernOn Tue, Oct 28, 2003 at 05:36:50PM -0000, Michael.Jacob@SCHERING.DE (via RT) wrote:
Damian, why does Attribute::Handlers do that?
That would break how can() works. Its supposed to pick up inherited -- |
From damian@conway.orgMichael G Schwern wrote:
Because of the OO-ish way in which Perl 5's built-in attribute handling is I don't have a good solution for you for this, short of entirely reworking Damian |
From @chipdudeAccording to Damian Conway:
What if you arranged for the class pushed onto @UNIVERSAL::ISA to have |
From Michael.Jacob@SCHERING.DEHi,
(Look at my second mail, I corrected my can() override.) It will only ignore methods that were ignore via UNIVERSAL from And most important, no side effects on other modules. It should make no Michael On Tue, Oct 28, 2003 at 05:36:50PM -0000, Michael.Jacob@SCHERING.DE (via
Damian, why does Attribute::Handlers do that?
That would break how can() works. Its supposed to pick up inherited -- |
From damian@conway.orgChip wrote:
That's do-able (modulo lack of tuits). About the only drawback would be the loss of the sensible error message I'll schedule it into my high priority ToDo list <bitter laughter>. Damian |
From damian@conway.orgPS: Forgive me, but I neglected to acknowledge that Chip's was an |
From alan@pair.comChip Salzenberg <chip@pobox.com> wrote:
Here is a patch which implements this tactic. It passes all Thanks, Alan Ferrency Inline Patch--- /usr/local/lib/perl5/site_perl/5.8.0/Attribute/Handlers.pm Sat Oct 5 01:40:19 2002
+++ lib/Attribute/Handlers.pm Tue Feb 17 14:16:07 2004
@@ -164,9 +164,10 @@
}
}
-*{"MODIFY_${_}_ATTRIBUTES"} = _gen_handler_AH_ foreach @{$validtype{ANY}};
-push @UNIVERSAL::ISA, 'Attribute::Handlers'
- unless grep /^Attribute::Handlers$/, @UNIVERSAL::ISA;
+*{"Attribute::Handlers::UNIVERSAL::MODIFY_${_}_ATTRIBUTES"} =
+ _gen_handler_AH_ foreach @{$validtype{ANY}};
+push @UNIVERSAL::ISA, 'Attribute::Handlers::UNIVERSAL'
+ unless grep /^Attribute::Handlers::UNIVERSAL$/, @UNIVERSAL::ISA;
sub _apply_handler_AH_ {
my ($declaration, $phase) = @_; |
From @rgsalan wrote:
I think it's correct. Thanks, I've applied this change to bleadperl
|
@rspier - Status changed from 'open' to 'resolved' |
From alan@pair.com
Thanks! I was beginning to think no one was listening :) Alan Ferrency On Mon, 23 Feb 2004, Rafael Garcia-Suarez wrote:
|
Migrated from rt.perl.org#24338 (status was 'resolved')
Searchable as RT24338$
The text was updated successfully, but these errors were encountered: