develooper Front page | perl.perl5.changes | Postings from November 2010

[perl.git] branch blead, updated. v5.13.7-129-g6a8c869

From:
Father Chrysostomos
Date:
November 27, 2010 07:15
Subject:
[perl.git] branch blead, updated. v5.13.7-129-g6a8c869
Message ID:
E1PMMVA-0007wx-Tz@camel.ams6.corp.booking.com
In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/6a8c86944bc507200cc01e245d39300e2e6ab775?hp=a51ee39bac6a83e6d63d3e6d8941ae352ef3546f>

- Log -----------------------------------------------------------------
commit 6a8c86944bc507200cc01e245d39300e2e6ab775
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Sat Nov 27 06:39:19 2010 -0800

    Add Devel:: to the -d:- perldelta entry

M	pod/perldelta.pod

commit 59773fc7ad0429c176256db6df5d7f80355bc993
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Sat Nov 27 06:37:58 2010 -0800

    perldelta up to a3179684

M	pod/perldelta.pod

commit 04698ff67968faa57a46c12d31e17c17baf08876
Author: Father Chrysostomos <sprout@cpan.org>
Date:   Sat Nov 27 06:22:24 2010 -0800

    [perl #79178] STORE/FETCH of tie()d hash get stringified key
    
    This bug has been present in non-threaded builds for a long time.
    Change 38bb37b9aa introduced it to threaded builds.
    
    $hash{...} makes its operand a shared-PV scalar if it is an OP_CONST.
    But \"foo" is also an OP_CONST, as is anything generated with use
    constant. This is the sort of thing that results:
    
    $ perl5.8.5 -MO=Concise -e '$a{\"foo"}'
    7  <@> leave[1 ref] vKP/REFC ->(end)
    1     <0> enter ->2
    2     <;> nextstate(main 1 -e:1) v ->3
    6     <2> helem vK/2 ->7
    4        <1> rv2hv sKR/1 ->5
    3           <$> gv(*a) s ->4
    5        <$> const(PVIV "SCALAR(0x81b378)") s ->6
    -e syntax OK
    
    (My 5.8.5 installation is non-threaded.)
    
    See the "SCALAR(0x81b378)" in there?
    
    So this commit skips that optimisation if the key is ROK or if it is a
    PVMG or higher.

M	op.c
M	t/op/hash.t
-----------------------------------------------------------------------

Summary of changes:
 op.c              |    3 ++-
 pod/perldelta.pod |   20 +++++++++++++++-----
 t/op/hash.t       |   18 +++++++++++++++++-
 3 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/op.c b/op.c
index 53641c7..4c3c876 100644
--- a/op.c
+++ b/op.c
@@ -9661,7 +9661,8 @@ Perl_rpeep(pTHX_ register OP *o)
 
 	    /* Make the CONST have a shared SV */
 	    svp = cSVOPx_svp(((BINOP*)o)->op_last);
-	    if (!SvFAKE(sv = *svp) || !SvREADONLY(sv)) {
+	    if ((!SvFAKE(sv = *svp) || !SvREADONLY(sv))
+	     && SvTYPE(sv) < SVt_PVMG && !SvROK(sv)) {
 		key = SvPV_const(sv, keylen);
 		lexname = newSVpvn_share(key,
 					 SvUTF8(sv) ? -(I32)keylen : (I32)keylen,
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 8b389aa..7e30a87 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -1,5 +1,8 @@
 =encoding utf8
 
+=for comment
+This has been completed up to a3179684.
+
 =head1 NAME
 
 [ this is a template for a new perldelta file. Any text flagged as
@@ -31,7 +34,8 @@ here, but most should go in the L</Performance Enhancements> section.
 =head2 C<-d:-foo> calls C<Devel::foo::unimport>
 
 The syntax C<-dI<B<:>foo>> was extended in 5.6.1 to make C<-dI<:fooB<=bar>>>
-equivalent to C<-Mfoo=bar>, which expands internally to C<use foo 'bar';>.
+equivalent to C<-MDevel::foo=bar>, which expands
+internally to C<use Devel::foo 'bar';>.
 F<perl> now allows prefixing the module name with C<->, with the same
 semantics as C<-M>, I<i.e.>
 
@@ -39,13 +43,14 @@ semantics as C<-M>, I<i.e.>
 
 =item C<-d:-foo>
 
-Equivalent to C<-M-foo>, expands to C<no foo;>, calls C<< foo->unimport() >>
+Equivalent to C<-M-Devel::foo>, expands to
+C<no Devel::foo;>, calls C<< Devel::foo->unimport() >>
 if the method exists.
 
 =item C<-d:-foo=bar>
 
-Equivalent to C<-M-foo=bar>, expands to C<no foo 'bar';>, calls
-C<< foo->unimport('bar') >> if the method exists.
+Equivalent to C<-M-Devel::foo=bar>, expands to C<no Devel::foo 'bar';>,
+calls C<< Devel::foo->unimport('bar') >> if the method exists.
 
 =back
 
@@ -77,6 +82,11 @@ listed as an updated module in the L</Modules and Pragmata> section.
 
 [ List each deprecation as a =head2 entry ]
 
+=head2 C<?PATTERN?> is deprecated
+
+C<?PATTERN?> (without the initial m) has been deprecated and now produces
+a warning.
+
 =head2 C<sv_compile_2op> is now deprecated
 
 The C<sv_compile_2op> is now deprecated, and will be removed. Searches suggest
@@ -147,7 +157,7 @@ C<Unicode::Collate> has been upgraded from 0.67 to 0.68
 
 =item *
 
-XXX
+C<Unicode::UCD> has been upgraded from 0.29 to 0.30.
 
 =back
 
diff --git a/t/op/hash.t b/t/op/hash.t
index d75d059..fe8a856 100644
--- a/t/op/hash.t
+++ b/t/op/hash.t
@@ -8,7 +8,7 @@ BEGIN {
 
 use strict;
 
-plan tests => 7;
+plan tests => 8;
 
 my %h;
 
@@ -130,3 +130,19 @@ $destroyed = 0;
     $h{key} = bless({}, 'Class');
 }
 is($destroyed, 1, 'Timely hash destruction with lvalue keys');
+
+
+# [perl #79178] Hash keys must not be stringified during compilation
+# Run perl -MO=Concise -e '$a{\"foo"}' on a non-threaded pre-5.13.8 version
+# to see why.
+{
+    my $key;
+    package bar;
+    sub TIEHASH { bless {}, $_[0] }
+    sub FETCH { $key = $_[1] }
+    package main;
+    tie my %h, "bar";
+    $h{\'foo'};
+    is ref $key, SCALAR =>
+     'hash keys are not stringified during compilation';
+}

--
Perl5 Master Repository



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About