This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Deprecate setting ${^ENCODING}
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Mon, 10 Nov 2014 23:54:46 +0000 (23:54 +0000)
committerKarl Williamson <khw@cpan.org>
Fri, 21 Nov 2014 04:45:18 +0000 (21:45 -0700)
The commiter added a no warnings in t/op/leaky-magic.t, and made other
minor changes because of rebasing issues.

mg.c
pod/perldiag.pod
pod/perlvar.pod
t/lib/warnings/mg
t/op/leaky-magic.t
t/re/pat_re_eval.t
t/uni/chomp.t

diff --git a/mg.c b/mg.c
index e9b61e8..679b309 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -2666,6 +2666,10 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
                 else { /* Use the regular global */
                     SvREFCNT_dec(PL_encoding);
                     if (SvOK(sv) || SvGMAGICAL(sv)) {
+                        if (PL_localizing != 2) {
+                            Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
+                                          "Setting ${^ENCODING} is deprecated");
+                        }
                         PL_encoding = newSVsv(sv);
                     }
                     else {
index d9dd692..2f4fa02 100644 (file)
@@ -5243,6 +5243,11 @@ a positive integer, where the integer was the address of the reference.
 As of Perl 5.20.0 this is a fatal error, to allow future versions of Perl
 to use non-integer refs for more interesting purposes.
 
+=item Setting ${^ENCODING} is deprecated
+
+(D deprecated) You assiged a non-C<undef> value to C<${^ENCODING}>.
+This is deprecated for the same reasons L<encoding> is deprecated.
+
 =item shift on reference is experimental
 
 (S experimental::autoderef) C<shift> with a scalar argument is experimental
index fe44c9d..61a2fdf 100644 (file)
@@ -1873,8 +1873,8 @@ X<${^ENCODING}>
 
 The I<object reference> to the C<Encode> object that is used to convert
 the source code to Unicode.  Thanks to this variable your Perl script
-does not have to be written in UTF-8.  Default is I<undef>.  The direct
-manipulation of this variable is highly discouraged.
+does not have to be written in UTF-8.  Default is I<undef>.  Setting
+this variable to any other value is deprecated.
 
 This variable was added in Perl 5.8.2.
 
index 348f9b2..6bd6c3a 100644 (file)
@@ -99,3 +99,16 @@ Use of uninitialized value $3 in oct at - line 3.
 use warnings 'uninitialized';
 $ENV{FOO} = undef; # should not warn
 EXPECT
+########
+${^ENCODING} = 42;
+{ local ${^ENCODING}; }
+${^ENCODING} = undef;
+{ local ${^ENCODING} = 37; }
+no warnings 'deprecated';
+${^ENCODING} = 42;
+{ local ${^ENCODING}; }
+${^ENCODING} = undef;
+{ local ${^ENCODING} = 37; }
+EXPECT
+Setting ${^ENCODING} is deprecated at - line 1.
+Setting ${^ENCODING} is deprecated at - line 4.
index 371f3ac..dd94d30 100644 (file)
@@ -34,6 +34,7 @@ ok !scalar keys %foo::SIG, "%foo::SIG";
 
 use tests 4; # rw ${^LETTERS} variables
 for(qw< CHILD_ERROR_NATIVE ENCODING UTF8CACHE WARNING_BITS >) {
+ no warnings 'deprecated';  # ENCODING is deprecated;
  my $name = s/./"qq|\\c$&|"/ere;
  local $$name = 'swit';
 
index c77439a..16ecf35 100644 (file)
@@ -744,7 +744,9 @@ sub run_tests {
                        # Poor man's "use encoding 'ascii'".
                        # This causes a different code path in S_const_str()
                        # to be used
+                       no warnings 'deprecated';
                        local ${^ENCODING} = $enc;
+                       use warnings 'deprecated';
                        use re 'eval';
                        ok($ss =~ /^$cc/, fmt("encode       $u->[2]", $ss, $cc));
                    }
index 4730736..c78c3e1 100644 (file)
@@ -33,7 +33,9 @@ our %mbchars = (
 plan tests => 2 * (4 ** 3 + 4 + 1) * (keys %mbchars);
 
 for my $enc (sort keys %mbchars) {
+    no warnings 'deprecated';
     local ${^ENCODING} = find_encoding($enc);
+    use warnings 'deprecated';
     my @char = (sort(keys   %{ $mbchars{$enc} }),
                sort(values %{ $mbchars{$enc} }));