summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2014-11-10 23:54:46 +0000
committerKarl Williamson <khw@cpan.org>2014-11-20 21:45:18 -0700
commitd5b4785c1592d741608f5cff697058cc284db4eb (patch)
tree4170769d989417e9385b841ad564798d2ca964db
parent050e2cbf5b64f9dc68666087f3ade51b110a3194 (diff)
downloadperl-d5b4785c1592d741608f5cff697058cc284db4eb.tar.gz
Deprecate setting ${^ENCODING}
The commiter added a no warnings in t/op/leaky-magic.t, and made other minor changes because of rebasing issues.
-rw-r--r--mg.c4
-rw-r--r--pod/perldiag.pod5
-rw-r--r--pod/perlvar.pod4
-rw-r--r--t/lib/warnings/mg13
-rw-r--r--t/op/leaky-magic.t1
-rw-r--r--t/re/pat_re_eval.t2
-rw-r--r--t/uni/chomp.t2
7 files changed, 29 insertions, 2 deletions
diff --git a/mg.c b/mg.c
index e9b61e8a7a..679b309f86 100644
--- 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 {
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index d9dd6921b2..2f4fa0284d 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -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
diff --git a/pod/perlvar.pod b/pod/perlvar.pod
index fe44c9d921..61a2fdfa42 100644
--- a/pod/perlvar.pod
+++ b/pod/perlvar.pod
@@ -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.
diff --git a/t/lib/warnings/mg b/t/lib/warnings/mg
index 348f9b245d..6bd6c3a912 100644
--- a/t/lib/warnings/mg
+++ b/t/lib/warnings/mg
@@ -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.
diff --git a/t/op/leaky-magic.t b/t/op/leaky-magic.t
index 371f3acbd6..dd94d30aa8 100644
--- a/t/op/leaky-magic.t
+++ b/t/op/leaky-magic.t
@@ -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';
diff --git a/t/re/pat_re_eval.t b/t/re/pat_re_eval.t
index c77439a38c..16ecf355f2 100644
--- a/t/re/pat_re_eval.t
+++ b/t/re/pat_re_eval.t
@@ -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));
}
diff --git a/t/uni/chomp.t b/t/uni/chomp.t
index 47307363bf..c78c3e1bde 100644
--- a/t/uni/chomp.t
+++ b/t/uni/chomp.t
@@ -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} }));