In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/569ba91fcdabdc53eb4284f860a25273bd7fe4e1?hp=b3ba608d9c8ad4dbd243bea977d4c9f3b6970329>

- Log -----------------------------------------------------------------
commit 569ba91fcdabdc53eb4284f860a25273bd7fe4e1
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 4 10:48:36 2012 -0800

    embed.fnc: Explain how X is used for public macros
    
    I don’t know whether my message to the list
    (<[email protected]>) was noticed.
    
    In any case, here it is for posterity.  Hopefully this will save
    others from finding this out the hard way as I had to (making mistakes
    and having others come and correct them).

M       embed.fnc

commit c071e2144a8a97e0c881f77dc08ef52613681a5c
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 4 10:44:08 2012 -0800

    Mention in more places that my $_ is deprecated

M       pod/perlfunc.pod
M       pod/perlsyn.pod

commit 90b58ec9e4b2574a8f7f11a0215f42453cfbc0a1
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 4 09:53:55 2012 -0800

    Deprecate lexical $_
    
    See tickets #114020 and #75598 for why.
    
    The changes to tests in cpan/Text-Tabs have been submitted upstream
    at rt.cpan.org #81698.

M       cpan/Text-Tabs/t/Tabs-ElCid.t
M       cpan/Text-Tabs/t/Wrap-JLB.t
M       ext/XS-APItest/t/underscore_length.t
M       op.c
M       pod/perldiag.pod
M       pod/perlvar.pod
M       t/comp/uproto.t
M       t/lib/warnings/9uninit
M       t/lib/warnings/op
M       t/op/coreamp.t
M       t/op/exec.t
M       t/op/mkdir.t
M       t/op/mydef.t
M       t/op/override.t
M       t/op/reverse.t
M       t/op/state.t
M       t/op/switch.t
M       t/re/pat_advanced.t
M       t/re/pat_rt_report.t
M       t/re/qr.t

commit 668a86254af1576eb43991facafcf3693c919b3f
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 4 07:04:48 2012 -0800

    encoding.t: Skip 2 tests under debugging

M       ext/PerlIO-encoding/t/encoding.t

commit 130a351361c970c569258bc0d5613f9542d9801d
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 4 06:57:58 2012 -0800

    Increase $sigtrap::VERSION to 1.07

M       lib/sigtrap.pm

commit a8e6f76f54394645f5d605301d81d4d0f7cd9422
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 4 06:57:02 2012 -0800

    sigtrap.pm: Avoid lexical $_
    
    my $_ is about to be deprecated.
    
    It has been using it since commit 972fc2eb7a to avoid modifying a
    read-only argument.  Using @{[...]} instead works, too.

M       lib/sigtrap.pm
-----------------------------------------------------------------------

Summary of changes:
 cpan/Text-Tabs/t/Tabs-ElCid.t        |    3 ++-
 cpan/Text-Tabs/t/Wrap-JLB.t          |    3 ++-
 embed.fnc                            |    7 +++++++
 ext/PerlIO-encoding/t/encoding.t     |   10 ++++++++++
 ext/XS-APItest/t/underscore_length.t |    2 +-
 lib/sigtrap.pm                       |    5 ++---
 op.c                                 |    7 +++++++
 pod/perldiag.pod                     |   12 ++++++++++++
 pod/perlfunc.pod                     |    6 ++++--
 pod/perlsyn.pod                      |    4 +++-
 pod/perlvar.pod                      |    3 ++-
 t/comp/uproto.t                      |    8 ++++++++
 t/lib/warnings/9uninit               |    1 +
 t/lib/warnings/op                    |   14 ++++++++++++++
 t/op/coreamp.t                       |    4 ++++
 t/op/exec.t                          |    1 +
 t/op/mkdir.t                         |    1 +
 t/op/mydef.t                         |    2 +-
 t/op/override.t                      |    1 +
 t/op/reverse.t                       |    1 +
 t/op/state.t                         |    1 +
 t/op/switch.t                        |    7 +++++++
 t/re/pat_advanced.t                  |    3 ++-
 t/re/pat_rt_report.t                 |    1 +
 t/re/qr.t                            |    1 +
 25 files changed, 96 insertions(+), 12 deletions(-)

diff --git a/cpan/Text-Tabs/t/Tabs-ElCid.t b/cpan/Text-Tabs/t/Tabs-ElCid.t
index 4208d51..32572e7 100644
--- a/cpan/Text-Tabs/t/Tabs-ElCid.t
+++ b/cpan/Text-Tabs/t/Tabs-ElCid.t
@@ -105,8 +105,9 @@ sub check($$$$) {
 
 sub check_data { 
 
+    local $_;
     binmode(DATA, ":utf8") || die "can't binmode DATA to utf8: $!";
-    while ( my $_ = <DATA> ) {
+    while ( <DATA> ) {
 
        my $bad = 0;
 
diff --git a/cpan/Text-Tabs/t/Wrap-JLB.t b/cpan/Text-Tabs/t/Wrap-JLB.t
index 2c40379..67163e2 100644
--- a/cpan/Text-Tabs/t/Wrap-JLB.t
+++ b/cpan/Text-Tabs/t/Wrap-JLB.t
@@ -87,7 +87,8 @@ sub check($$$$) {
 sub check_data { 
 
     binmode(DATA, ":utf8") || die "can't binmode DATA to utf8: $!";
-    while ( my $_ = <DATA> ) {
+    local $_;
+    while ( <DATA> ) {
 
        my $bad = 0;
 
diff --git a/embed.fnc b/embed.fnc
index 4e3d825..e7ac5f1 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -16,6 +16,9 @@
 :         any doc entry goes in perlapi.pod rather than perlintern.pod
 :         makes '#define foo Perl_foo' scope not just for PERL_CORE/PERL_EXT
 :
+:      If the function is only exported for use in a public
+:      macro, see X.
+:
 :   a  Allocates memory a la malloc/calloc.  Also implies "R":
 :
 :         proto.h: add __attribute__malloc__
@@ -111,6 +114,10 @@
 :
 :         add entry to the list of exported symbols, unless x or m
 :
+:      This is often used for private functions that are used by public
+:      macros.  In those cases the macros must use the long form of the
+:      name (Perl_blah(aTHX_ ...)).
+:
 :   x  Not exported
 :
 :         suppress entry in the list of exported symbols
diff --git a/ext/PerlIO-encoding/t/encoding.t b/ext/PerlIO-encoding/t/encoding.t
index b9193b9..6b4d3d0 100644
--- a/ext/PerlIO-encoding/t/encoding.t
+++ b/ext/PerlIO-encoding/t/encoding.t
@@ -206,6 +206,14 @@ package Globber {
 # important.
 # We need a double eval, as scope unwinding will close the handle,
 # which croaks.
+# Under debugging builds with PERL_DESTRUCT_LEVEL set, we have to skip this
+# test, as it triggers bug #115692, resulting in string table warnings.
+require Config;
+SKIP: {
+skip "produces string table warnings", 2
+  if "@{[Config::non_bincompat_options()]}" =~ /\bDEBUGGING\b/
+   && $ENV{PERL_DESTRUCT_LEVEL};
+
 eval { eval {
     open my $fh, ">:encoding(globber)", \$buf;
     print $fh "Agathopous Goodfoot\n";
@@ -220,6 +228,8 @@ close $fh;
 is $x, "To hymn him who heard her herd herd\n",
      'no crash when assigning glob to buffer in decode';
 
+} # SKIP
+
 END {
     1 while unlink($grk, $utf, $fail1, $fail2, $russki, $threebyte);
 }
diff --git a/ext/XS-APItest/t/underscore_length.t 
b/ext/XS-APItest/t/underscore_length.t
index 7ca6906..32698f9 100644
--- a/ext/XS-APItest/t/underscore_length.t
+++ b/ext/XS-APItest/t/underscore_length.t
@@ -1,4 +1,4 @@
-use warnings;
+use warnings; no warnings 'deprecated';
 use strict;
 
 use Test::More tests => 4;
diff --git a/lib/sigtrap.pm b/lib/sigtrap.pm
index 025845e..df728c8 100644
--- a/lib/sigtrap.pm
+++ b/lib/sigtrap.pm
@@ -8,7 +8,7 @@ sigtrap - Perl pragma to enable simple signal handling
 
 use Carp;
 
-$VERSION = 1.06;
+$VERSION = 1.07;
 $Verbose ||= 0;
 
 sub import {
@@ -95,8 +95,7 @@ sub handler_traceback {
     # Now go for broke.
     for ($i = 1; ($p,$f,$l,$s,$h,$w,$e,$r) = caller($i); $i++) {
         @a = ();
-       for my $fr (@args) {
-            my $_ = $fr;
+       for (@{[@args]}) {
            s/([\'\\])/\\$1/g;
            s/([^\0]*)/'$1'/
              unless /^(?: -?[\d.]+ | \*[\w:]* )$/x;
diff --git a/op.c b/op.c
index 18afb4b..b0a3073 100644
--- a/op.c
+++ b/op.c
@@ -578,6 +578,13 @@ Perl_allocmy(pTHX_ const char *const name, const STRLEN 
len, const U32 flags)
                              PL_parser->in_my == KEY_state ? "state" : "my"), 
flags & SVf_UTF8);
        }
     }
+    else if (len == 2 && name[1] == '_' && !is_our)
+       /* diag_listed_as: Use of my $_ is deprecated */
+       Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
+                             "Use of %s $_ is deprecated",
+                              PL_parser->in_my == KEY_state
+                                ? "state"
+                                : "my");
 
     /* allocate a spare slot and store the name in that slot */
 
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 1a21297..dfa9a7d 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -5585,6 +5585,12 @@ old way has bad side effects.
 it already went past any symlink you are presumably trying to look for.
 The operation returned C<undef>.  Use a filename instead.
 
+=item Use of my $_ is deprecated
+
+(D deprecated) Lexical $_ is deprecated because of
+its confusing side-effects.  Consider using C<local $_>
+instead.  See the explanation under L<perlvar/$_>.
+
 =item Use of %s on a handle without * is deprecated
 
 (D deprecated) You used C<tie>, C<tied> or C<untie> on a scalar but that scalar
@@ -5616,6 +5622,12 @@ C<$array[0+$ref]>.  This warning is not given for 
overloaded objects,
 however, because you can overload the numification and stringification
 operators and then you presumably know what you are doing.
 
+=item Use of state $_ is deprecated
+
+(D deprecated) Lexical $_ is deprecated because of
+its confusing side-effects.  Consider using C<local $_>
+instead.  See the explanation under L<perlvar/$_>.
+
 =item Use of tainted arguments in %s is deprecated
 
 (W taint, deprecated) You have supplied C<system()> or C<exec()> with multiple
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 6a7dcdb..f39974e 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -2968,7 +2968,8 @@ or another C<grep>) actually modifies the element in the 
original list.
 This is usually something to be avoided when writing clear code.
 
 If C<$_> is lexical in the scope where the C<grep> appears (because it has
-been declared with C<my $_>) then, in addition to being locally aliased to
+been declared with the deprecated C<my $_> construct)
+then, in addition to being locally aliased to
 the list elements, C<$_> keeps being lexical inside the block; i.e., it
 can't be seen from the outside, avoiding any potential side-effects.
 
@@ -3613,7 +3614,8 @@ most cases.  See also L</grep> for an array composed of 
those items of
 the original list for which the BLOCK or EXPR evaluates to true.
 
 If C<$_> is lexical in the scope where the C<map> appears (because it has
-been declared with C<my $_>), then, in addition to being locally aliased to
+been declared with the deprecated C<my $_> construct),
+then, in addition to being locally aliased to
 the list elements, C<$_> keeps being lexical inside the block; that is, it
 can't be seen from the outside, avoiding any potential side-effects.
 
diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod
index fe473f6..0d8fd0d 100644
--- a/pod/perlsyn.pod
+++ b/pod/perlsyn.pod
@@ -651,7 +651,9 @@ dynamically scoped alias to the original, as it would be if 
it were a
 C<foreach> or under both the original and the current Perl 6 language
 specification.  This bug was fixed in Perl
 5.18.  If you really want a lexical C<$_>,
-specify that explicitly:
+specify that explicitly, but note that C<my $_>
+is now deprecated and will warn unless warnings
+have been disabled:
 
     given(my $_ = EXPR) { ... }
 
diff --git a/pod/perlvar.pod b/pod/perlvar.pod
index 2ce9e3b..47b202a 100644
--- a/pod/perlvar.pod
+++ b/pod/perlvar.pod
@@ -155,7 +155,8 @@ actually causes more problems than it solves.  If you call 
a function that
 expects to be passed information via C<$_>, it may or may not work,
 depending on how the function is written, there not being any easy way to
 solve this.  Just avoid lexical C<$_>, unless you are feeling particularly
-masochistic.
+masochistic.  For this reason lexical C<$_> is deprecated and will produce
+a warning unless warnings have been disabled.
 
 Mnemonic: underline is understood in certain operations.
 
diff --git a/t/comp/uproto.t b/t/comp/uproto.t
index d3ad19f..f81e314 100644
--- a/t/comp/uproto.t
+++ b/t/comp/uproto.t
@@ -72,7 +72,11 @@ eval q{ f(1,2,3,4) };
 like( $@, qr/Too many arguments for main::f at/ );
 
 {
+    # We have not tested require/use/no yet, so we must avoid this:
+    #    no warnings 'deprecated';
+    BEGIN { $SIG{__WARN__} = sub {} }
     my $_ = "quarante-deux";
+    BEGIN { $SIG{__WARN__} = undef }
     $foo = "FOO";
     $bar = "BAR";
     f("FOO quarante-deux", $foo);
@@ -97,7 +101,9 @@ $_ = $expected;
 g();
 g;
 undef $expected; &g; # $_ not passed
+BEGIN { $SIG{__WARN__} = sub {} }
 { $expected = my $_ = "bar"; g() }
+BEGIN { $SIG{__WARN__} = undef }
 
 eval q{ sub wrong1 (_$); wrong1(1,2) };
 like( $@, qr/Malformed prototype for main::wrong1/, 'wrong1' );
@@ -142,7 +148,9 @@ $_ = 21;
 double();
 is( $_, 42, '$_ is modifiable' );
 {
+    BEGIN { $SIG{__WARN__} = sub {} }
     my $_ = 22;
+    BEGIN { $SIG{__WARN__} = undef }
     double();
     is( $_, 44, 'my $_ is modifiable' );
 }
diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit
index 2877f14..c34c22f 100644
--- a/t/lib/warnings/9uninit
+++ b/t/lib/warnings/9uninit
@@ -820,6 +820,7 @@ undef $g1;
 $m1 = '$g1';
 $foo =~ s//$m1/ee;
 EXPECT
+Use of my $_ is deprecated at - line 16.
 Use of uninitialized value $_ in pattern match (m//) at - line 5.
 Use of uninitialized value $m1 in regexp compilation at - line 6.
 Use of uninitialized value $_ in pattern match (m//) at - line 6.
diff --git a/t/lib/warnings/op b/t/lib/warnings/op
index 3e9ea41..d8e43d7 100644
--- a/t/lib/warnings/op
+++ b/t/lib/warnings/op
@@ -1,5 +1,8 @@
   op.c         AOK
 
+     Use of my $_ is deprecated
+       my $_ ;
+
      Found = in conditional, should be ==
        1 if $a = 1 ;
 
@@ -104,6 +107,17 @@
     
 __END__
 # op.c
+use warnings 'deprecated' ;
+my $_;
+CORE::state $_;
+no warnings 'deprecated' ;
+my $_;
+CORE::state $_;
+EXPECT
+Use of my $_ is deprecated at - line 3.
+Use of state $_ is deprecated at - line 4.
+########
+# op.c
 use warnings 'syntax' ;
 1 if $a = 1 ;
 1 if $a
diff --git a/t/op/coreamp.t b/t/op/coreamp.t
index 477325d..7b9c1dd 100644
--- a/t/op/coreamp.t
+++ b/t/op/coreamp.t
@@ -86,6 +86,7 @@ sub test_proto {
     # works in all cases.
     undef $_;
     {
+      no warnings 'deprecated';
       my $_ = $in;
       is &{"CORE::$o"}(), $out, "&$o with no args uses lexical \$_";
     }
@@ -93,6 +94,7 @@ sub test_proto {
     my $r;
     $r = sub {
       if($_[0]) {
+        no warnings 'deprecated';
         my $_ = $in;
         is &{"CORE::$o"}(), $out,
            "&$o with no args uses the right lexical \$_ under recursion";
@@ -102,6 +104,7 @@ sub test_proto {
       }
     };
     &$r(0);
+    no warnings 'deprecated';
     my $_ = $in;
     eval {
        is "CORE::$o"->(), $out, "&$o with the right lexical \$_ in an eval"
@@ -1013,6 +1016,7 @@ like $@, qr'^Undefined format "STDOUT" called',
   my $warnings;
   local $SIG{__WARN__} = sub { ++$warnings };
 
+  no warnings 'deprecated';
   my $_ = 'Phoo';
   ok &mymkdir(), '&mkdir';
   like <*>, qr/^phoo(.DIR)?\z/i, 'mkdir works with implicit $_';
diff --git a/t/op/exec.t b/t/op/exec.t
index fb0b104..09311c5 100644
--- a/t/op/exec.t
+++ b/t/op/exec.t
@@ -124,6 +124,7 @@ $Perl -le "print 'ok'"
 END
 
 {
+    no warnings 'deprecated';
     my $_ = qq($Perl -le "print 'ok'");
     is( readpipe, "ok\n", 'readpipe default argument' );
 }
diff --git a/t/op/mkdir.t b/t/op/mkdir.t
index ebbbd2e..6bbd100 100644
--- a/t/op/mkdir.t
+++ b/t/op/mkdir.t
@@ -48,6 +48,7 @@ ok(!-d);
 $_ = 'lfrulb';
 
 {
+    no warnings 'deprecated';
     my $_ = 'blurfl';
     ok(mkdir);
     ok(-d);
diff --git a/t/op/mydef.t b/t/op/mydef.t
index 335033b..1480ce3 100644
--- a/t/op/mydef.t
+++ b/t/op/mydef.t
@@ -7,7 +7,7 @@ BEGIN {
 }
 
 use strict;
-no warnings 'misc';
+no warnings 'misc', 'deprecated';
 
 $_ = 'global';
 is($_, 'global', '$_ initial value');
diff --git a/t/op/override.t b/t/op/override.t
index 9eb22e0..e62f785 100644
--- a/t/op/override.t
+++ b/t/op/override.t
@@ -63,6 +63,7 @@ is( $r, join($dirsep, "Foo", "Bar.pm") );
 }
 
 {
+    no warnings 'deprecated';
     my $_ = 'bar.pm';
     require;
     is( $r, 'bar.pm' );
diff --git a/t/op/reverse.t b/t/op/reverse.t
index bbc9336..d4d43f8 100644
--- a/t/op/reverse.t
+++ b/t/op/reverse.t
@@ -94,6 +94,7 @@ use Tie::Array;
 
 {
     # Lexical $_.
+    no warnings 'deprecated';
     sub blurp { my $_ = shift; reverse }
 
     is(blurp("foo"), "oof", 'reversal of default variable in function');
diff --git a/t/op/state.t b/t/op/state.t
index 65f368b..91cc4b7 100644
--- a/t/op/state.t
+++ b/t/op/state.t
@@ -211,6 +211,7 @@ my $first  = $stones [0];
 my $First  = ucfirst $first;
 $_ = "bambam";
 foreach my $flint (@stones) {
+    no warnings 'deprecated';
     state $_ = $flint;
     is $_, $first, 'state $_';
     ok /$first/, '/.../ binds to $_';
diff --git a/t/op/switch.t b/t/op/switch.t
index 02e2cde..439df50 100644
--- a/t/op/switch.t
+++ b/t/op/switch.t
@@ -55,6 +55,7 @@ given("inside") { check_outside1() }
 sub check_outside1 { is($_, "inside", "\$_ is not lexically scoped") }
 
 {
+    no warnings 'deprecated';
     my $_ = "outside";
     given("inside") { check_outside2() }
     sub check_outside2 {
@@ -397,6 +398,7 @@ sub check_outside1 { is($_, "inside", "\$_ is not lexically 
scoped") }
 
 # Make sure it still works with a lexical $_:
 {
+    no warnings 'deprecated';
     my $_;
     my $test = "explicit comparison with lexical \$_";
     my $twenty_five = 25;
@@ -697,6 +699,7 @@ my $f = tie my $v, "FetchCounter";
 
 {
     my $first = 1;
+    no warnings 'deprecated';
     my $_;
     for (1, "two") {
        when ("two") {
@@ -715,6 +718,7 @@ my $f = tie my $v, "FetchCounter";
 
 {
     my $first = 1;
+    no warnings 'deprecated';
     my $_;
     for $_ (1, "two") {
        when ("two") {
@@ -733,6 +737,7 @@ my $f = tie my $v, "FetchCounter";
 
 {
     my $first = 1;
+    no warnings 'deprecated';
     for my $_ (1, "two") {
        when ("two") {
            is($first, 0, "Lexical loop: second");
@@ -1366,6 +1371,7 @@ unreified_check(undef,"");
 
 {
     sub f1 {
+       no warnings 'deprecated';
        my $_;
        given(3) {
            return sub { $_ } # close over lexical $_
@@ -1379,6 +1385,7 @@ unreified_check(undef,"");
     sub DESTROY { $d++ };
 
     sub f2 {
+       no warnings 'deprecated';
        my $_ = 5;
        given(bless [7]) {
            ::is($_->[0], 7, "is [7]");
diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t
index 7a38d41..2d4706a 100644
--- a/t/re/pat_advanced.t
+++ b/t/re/pat_advanced.t
@@ -1615,7 +1615,7 @@ sub run_tests {
     {
         # Test for keys in %+ and %-
         my $message = 'Test keys in %+ and %-';
-        no warnings 'uninitialized';
+        no warnings 'uninitialized', 'deprecated';
         my $_ = "abcdef";
         /(?<foo>a)|(?<foo>b)/;
         is((join ",", sort keys %+), "foo", $message);
@@ -1636,6 +1636,7 @@ sub run_tests {
 
     {
         # length() on captures, the numbered ones end up in Perl_magic_len
+        no warnings 'deprecated';
         my $_ = "aoeu \xe6var ook";
         /^ \w+ \s (?<eek>\S+)/x;
 
diff --git a/t/re/pat_rt_report.t b/t/re/pat_rt_report.t
index d19d1df..54c2d05 100644
--- a/t/re/pat_rt_report.t
+++ b/t/re/pat_rt_report.t
@@ -915,6 +915,7 @@ sub run_tests {
     {
          my $message = '$REGMARK in replacement; Bug 49190';
          our $REGMARK;
+         no warnings 'deprecated';
          my $_ = "A";
          ok(s/(*:B)A/$REGMARK/, $message);
          is($_, "B", $message);
diff --git a/t/re/qr.t b/t/re/qr.t
index 1378772..ee68d63 100644
--- a/t/re/qr.t
+++ b/t/re/qr.t
@@ -33,6 +33,7 @@ is(ref $rx, "Regexp", "qr// blessed into 'Regexp' by 
default");
 
  is $output, "5\n1: 5\n2: 5\n", '$a_match_var =~ /$qr/';
 }
+no warnings 'deprecated';
 for my $_($'){
  my $output = '';
  my $rx = qr/o/;

--
Perl5 Master Repository

Reply via email to