diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-06-04 11:54:10 -0700 |
---|---|---|
committer | Florian Ragwitz <rafl@debian.org> | 2011-09-05 01:39:02 +0200 |
commit | 61b414c74759c0fd9da9a2e9f3d1a9b4d8b6b492 (patch) | |
tree | fadbe4bb24e3017c2ca08be8cdc765bd24c51d9e | |
parent | d76d79d99e1403cb2d9430ba403a4f7c0e95f96c (diff) | |
download | perl-61b414c74759c0fd9da9a2e9f3d1a9b4d8b6b492.tar.gz |
Allow COW values to be deleted from restricted hashes
I wonder how many other things a604c75 broke....
-rw-r--r-- | dist/base/t/fields.t | 8 | ||||
-rw-r--r-- | hv.c | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/dist/base/t/fields.t b/dist/base/t/fields.t index 4999cfed14..a3493ce2ee 100644 --- a/dist/base/t/fields.t +++ b/dist/base/t/fields.t @@ -6,7 +6,7 @@ BEGIN { } use strict; -use Test::More tests => 16; +use Test::More tests => 17; BEGIN { use_ok('fields'); } @@ -106,4 +106,10 @@ package main; is(ref $x, 'Test::FooBar', 'x is a Test::FooBar'); ok(exists $x->{a}, 'x has a'); ok(exists $x->{b}, 'x has b'); + + SKIP: { + skip "This test triggers a perl bug", 1 if $] < 5.014001; + $x->{a} = __PACKAGE__; + ok eval { delete $x->{a}; 1 }, 'deleting COW values'; + } } @@ -1012,7 +1012,8 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, Safefree(key); return NULL; } - if (SvREADONLY(hv) && HeVAL(entry) && SvREADONLY(HeVAL(entry))) { + if (SvREADONLY(hv) && HeVAL(entry) && SvREADONLY(HeVAL(entry)) + && !SvIsCOW(HeVAL(entry))) { hv_notallowed(k_flags, key, klen, "Attempt to delete readonly key '%"SVf"' from" " a restricted hash"); |