Subject: | Weakening references |
Hi,
The call to weaken() function (from Incremental.pm) prints the warning if the reference which was passed to it as
a parameter is already weak:
----------------------------------------------
Reference is already weak at /usr/lib/perl5/vendor_perl/5.8.8/XML/SAX/Expat/Incremental.pm line 85.
----------------------------------------------
The remedy would be to check if the reference is actually weak before making call to weaken(). The following patch
could be applied:
---------------------%<-----------------------
--- Incremental.pm_orig 2010-09-14 11:12:30.000000000 +0200
+++ Incremental.pm 2010-09-14 11:31:06.000000000 +0200
@@ -11,7 +11,7 @@
use XML::Parser ();
use Carp qw/croak/;
-use Scalar::Util qw/weaken/;
+use Scalar::Util qw/weaken isweak/;
sub parse {
my $p = shift;
@@ -82,14 +82,14 @@
sub _expat_obj {
my $p = shift;
$p->{_expat_nb_obj} = shift if @_;
- weaken($p->{_expat_nb_obj});
+ weaken($p->{_expat_nb_obj}) if not isweak ($p->{_expat_nb_obj});
$p->{_expat_nb_obj};
}
sub _parser_obj {
my $p = shift;
$p->{_xml_parser_obj} = shift if @_;
- weaken($p->{_xml_parser_obj}{__XSE}); # FIXME should go away
+ weaken($p->{_xml_parser_obj}{__XSE}) if not isweak ($p->{_xml_parser_obj}{__XSE}); # FIXME should go away
$p->{_xml_parser_obj};
}
---------------------%<-----------------------
Cheers,
Artem.
----------------------------------------------
Distribution name and version - XML::SAX::Expat::Incremental (0.05)
Perl version: perl -v
*****
This is perl, v5.8.8 built for i386-linux-thread-multi
Copyright 1987-2006, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
*****
Operating System vendor and version:
Linux localhost.localdomain 2.6.18-194.3.1.el5 #1 SMP Fri May 7 01:52:57 EDT 2010 i686 i686 i386 GNU/Linux uname -
a
----------------------------------------------