Closed p5pRT closed 20 years ago
with 5.8.2 and 5.6.1 (and presumably 5.6.2)
perl -MScalar::Util=weaken -e '$a=\"h";weaken($a)' Modification of a read-only value attempted at -e line 1
this means that you probaly should be doing
eval { local $SIG{__DIE__}; weaken($a); };
wherever you were using it before. Patch attached to fix this by adding PERL_MAGIC_backref to the list of things that can be done to a readonly value.
I added some tests\, everything still passes\, is there some other reason not to allow this?
F
Previous patch included an unrelated patch to Exporter.pm\, this one is for weaken only\,
F
3rd attempt to get this mail through to the list...
With blead\, 5.8.2 and probably all perls that have weak refs
perl -MScalar::Util=weaken -e '$a=\"h";weaken($a)' Modification of a read-only value attempted at -e line 1
Any good reason for this? It's not documented and it's a pain.
If you want to weaken refs of unknown origin (eg in a generic cache module) then you actually have to do
eval { local $SIG{__DIE__}; weaken($ref); };
And also you end up with read only refs that don't get garbage collected when they should [1].
Patch for blead attached to fix this by adding PERL_MAGIC_backref to the list of things that can be done to a readonly value. Also applied to 5.8 and maybe 5.6.
I added some tests\, everything still passes\, is there some other reason not to allow this?
F
[1] It's rare that you get a GC'able read only ref but
$r = eval '\"hello"'
produces one.
Fergal Daly wrote:
With blead\, 5.8.2 and probably all perls that have weak refs
perl -MScalar::Util=weaken -e '$a=\"h";weaken($a)' Modification of a read-only value attempted at -e line 1
Any good reason for this? It's not documented and it's a pain.
If you want to weaken refs of unknown origin (eg in a generic cache module) then you actually have to do
eval { local $SIG{__DIE__}; weaken($ref); };
And also you end up with read only refs that don't get garbage collected when they should [1].
Yes.
Patch for blead attached to fix this by adding PERL_MAGIC_backref to the list of things that can be done to a readonly value. Also applied to 5.8 and maybe 5.6.
This makes me a bit nervous\, but I think it's correct ; in fact I was looking at it currently.
I added some tests\, everything still passes\, is there some other reason not to allow this?
I noticed a Point of Style : you patched the core but added a test in a CPAN module. This test will obviously fail when backported to CPAN. There are two solutions -- either put the test in a separate file\, or skip it for $] \< 5.009 or $] == 5.009 && ! $ENV{PERL_CORE}.
Graham\, any comments on this ?
On 2 Dec 2003\, at 23:31\, Rafael Garcia-Suarez wrote:
I added some tests\, everything still passes\, is there some other reason not to allow this?
I noticed a Point of Style : you patched the core but added a test in a CPAN module. This test will obviously fail when backported to CPAN. There are two solutions -- either put the test in a separate file\, or skip it for $] \< 5.009 or $] == 5.009 && ! $ENV{PERL_CORE}.
Graham\, any comments on this ?
I would make it so that the test is skipped for $] \< 5.009
Graham.
On Wednesday 03 December 2003 22:19\, Graham Barr via RT wrote:
I would make it so that the test is skipped for $] \< 5.009
Graham.
Before I do that\, any chance I could convert the script to use Test::More as the testing framework? It makes everything a bit easier. I'll even convert the other test scripts for free\,
F
Graham Barr wrote:
On 2 Dec 2003\, at 23:31\, Rafael Garcia-Suarez wrote:
I added some tests\, everything still passes\, is there some other reason not to allow this?
I noticed a Point of Style : you patched the core but added a test in a CPAN module. This test will obviously fail when backported to CPAN. There are two solutions -- either put the test in a separate file\, or skip it for $] \< 5.009 or $] == 5.009 && ! $ENV{PERL_CORE}.
Graham\, any comments on this ?
I would make it so that the test is skipped for $] \< 5.009
OK. I thus applied Fergal's patch (thanks) as:
Change 21955 by rgs@rgs-home on 2003/12/25 18:59:54
Subject: [perl #24506] [PATCH] cannot weaken refs to read only values
From: Fergal Daly \fergal@​esatclear\.ie
Date: Tue\, 2 Dec 2003 23:18:18 +0000
Message-Id: \200312022318\.18353\.fergal@​esatclear\.ie
(tweaked so the test is skipped on perls \< 5.9.0)
Affected files ...
... //depot/perl/ext/List/Util/t/weak.t#3 edit ... //depot/perl/sv.c#707 edit
@rgs - Status changed from 'new' to 'resolved'
On 25 Dec 2003\, at 19:25\, Rafael Garcia-Suarez wrote:
Graham Barr wrote:
On 2 Dec 2003\, at 23:31\, Rafael Garcia-Suarez wrote:
I added some tests\, everything still passes\, is there some other reason not to allow this?
I noticed a Point of Style : you patched the core but added a test in a CPAN module. This test will obviously fail when backported to CPAN. There are two solutions -- either put the test in a separate file\, or skip it for $] \< 5.009 or $] == 5.009 && ! $ENV{PERL_CORE}.
Graham\, any comments on this ?
I would make it so that the test is skipped for $] \< 5.009
OK. I thus applied Fergal's patch (thanks) as:
Change 21955 by rgs@rgs-home on 2003/12/25 18:59:54
Subject​: \[perl \#24506\] \[PATCH\] cannot weaken refs to read only
values From: Fergal Daly \fergal@​esatclear\.ie Date: Tue\, 2 Dec 2003 23:18:18 +0000 Message-Id: \200312022318\.18353\.fergal@​esatclear\.ie
\(tweaked so the test is skipped on perls \< 5\.9\.0\)
I saw that\, Thanks.
I am a bit tied up with family stuff over the holidays\, but I will do a CPAN release when I can.
Graham.
Migrated from rt.perl.org#24506 (status was 'resolved')
Searchable as RT24506$