summaryrefslogtreecommitdiff
path: root/dist/encoding-warnings
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2016-05-22 13:51:14 -0700
committerFather Chrysostomos <sprout@cpan.org>2016-07-13 01:12:46 -0700
commitb907137092fee3543ab991649fc6a69d6c97f964 (patch)
tree63bb2b5f5726eec77b99d1886d76e0affd340101 /dist/encoding-warnings
parent5cd8b2253cf1f6f21dce7c3402b05c886f4da099 (diff)
downloadperl-b907137092fee3543ab991649fc6a69d6c97f964.tar.gz
Make encoding::warnings a no-op in 5.26
with a single warning at import time.
Diffstat (limited to 'dist/encoding-warnings')
-rw-r--r--dist/encoding-warnings/lib/encoding/warnings.pm24
-rw-r--r--dist/encoding-warnings/t/1-warning.t20
-rw-r--r--dist/encoding-warnings/t/2-fatal.t4
-rw-r--r--dist/encoding-warnings/t/3-normal.t7
-rw-r--r--dist/encoding-warnings/t/4-lexical.t4
5 files changed, 56 insertions, 3 deletions
diff --git a/dist/encoding-warnings/lib/encoding/warnings.pm b/dist/encoding-warnings/lib/encoding/warnings.pm
index d5c4184130..3e76b0bc83 100644
--- a/dist/encoding-warnings/lib/encoding/warnings.pm
+++ b/dist/encoding-warnings/lib/encoding/warnings.pm
@@ -13,6 +13,20 @@ encoding::warnings - Warn on implicit encoding conversions
This document describes version 0.11 of encoding::warnings, released
June 5, 2007.
+=head1 NOTICE
+
+As of Perl 5.26.0, this module has no effect. The internal Perl feature
+that was used to implement this module has been removed. In recent years,
+much work has been done on the Perl core to eliminate discrepancies in the
+treatment of upgraded versus downgraded strings. In addition, the
+L<encoding> pragma, which caused many of the problems, is no longer
+supported. Thus, the warnings this module produced are no longer
+necessary.
+
+Hence, if you load this module on Perl 5.26.0, you will get one warning
+that the module is no longer supported; and the module will do nothing
+thereafter.
+
=head1 SYNOPSIS
use encoding::warnings; # or 'FATAL' to raise fatal exceptions
@@ -146,8 +160,16 @@ sub ASCII () { 0 }
sub LATIN1 () { 1 }
sub FATAL () { 2 }
-# Install a ${^ENCODING} handler if no other one are already in place.
sub import {
+ if ($] >= 5.025003) {
+ require Carp;
+ Carp::cluck(
+ "encoding::warnings is not supported on Perl 5.26.0 and later"
+ );
+ return;
+ }
+
+ # Install a ${^ENCODING} handler if no other one are already in place.
my $class = shift;
my $fatal = shift || '';
diff --git a/dist/encoding-warnings/t/1-warning.t b/dist/encoding-warnings/t/1-warning.t
index 9b04cb6767..fa0bb6e475 100644
--- a/dist/encoding-warnings/t/1-warning.t
+++ b/dist/encoding-warnings/t/1-warning.t
@@ -14,9 +14,25 @@ BEGIN {
}
use Test;
-BEGIN { plan tests => 2 }
-
use strict;
+
+BEGIN {
+ if ("$]" >= 5.025) {
+ # Test the new almost-noop behaviour in new perls.
+ plan tests => 3;
+ my $w;
+ $SIG{__WARN__} = sub { $w .= shift };
+ require encoding::warnings;
+ ok $w, undef, 'no warning from requiring encoding::warnings';
+ ok(encoding::warnings->VERSION);
+ encoding::warnings->import;
+ ok $w, qr/^encoding::warnings is not supported /, 'import warning';
+ exit;
+ }
+ # else continue with your usual scheduled testing...
+ plan tests => 2;
+}
+
use encoding::warnings;
ok(encoding::warnings->VERSION);
diff --git a/dist/encoding-warnings/t/2-fatal.t b/dist/encoding-warnings/t/2-fatal.t
index ef001814df..d2928cd1f1 100644
--- a/dist/encoding-warnings/t/2-fatal.t
+++ b/dist/encoding-warnings/t/2-fatal.t
@@ -3,6 +3,10 @@
# $Revision: #4 $ $Change: 1626 $ $DateTime: 2004-03-14T16:53:19.351256Z $
BEGIN {
+ if ("$]" >= 5.025) {
+ print "1..0 # Skip: encoding::warnings not supported on perl 5.26\n";
+ exit 0;
+ }
if (ord("A") != 65) {
print "1..0 # Skip: Encode not working on EBCDIC\n";
exit 0;
diff --git a/dist/encoding-warnings/t/3-normal.t b/dist/encoding-warnings/t/3-normal.t
index f0e6446a56..a66798bb73 100644
--- a/dist/encoding-warnings/t/3-normal.t
+++ b/dist/encoding-warnings/t/3-normal.t
@@ -1,3 +1,10 @@
+BEGIN {
+ if ("$]" >= 5.025) {
+ print "1..0 # Skip: encoding::warnings not supported on perl 5.26\n";
+ exit 0;
+ }
+}
+
use Test;
BEGIN { plan tests => 2 }
diff --git a/dist/encoding-warnings/t/4-lexical.t b/dist/encoding-warnings/t/4-lexical.t
index bdd9f21eec..0f6b4c1933 100644
--- a/dist/encoding-warnings/t/4-lexical.t
+++ b/dist/encoding-warnings/t/4-lexical.t
@@ -1,6 +1,10 @@
use strict;
use Test;
BEGIN {
+ if ("$]" >= 5.025) {
+ print "1..0 # Skip: encoding::warnings not supported on perl 5.26\n";
+ exit 0;
+ }
if (ord("A") != 65) {
print "1..0 # Skip: Encode not working on EBCDIC\n";
exit 0;