This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Prevent hostname() from accepting arguments
authorJames E Keenan <jkeenan@cpan.org>
Sat, 25 May 2019 02:37:40 +0000 (22:37 -0400)
committerJames E Keenan <jkeenan@cpan.org>
Wed, 5 Jun 2019 00:11:24 +0000 (20:11 -0400)
Previously deprecated; now fatal.

Incorporate feedback from Tony Cook and Richard Leach as to wording of
exception and how it is invoked.

For: RT 134137

ext/Sys-Hostname/Hostname.pm
ext/Sys-Hostname/t/Hostname.t

index 8b5dde1..2284e1f 100644 (file)
@@ -16,7 +16,7 @@ use warnings ();
 our $host;
 
 BEGIN {
-    $VERSION = '1.22';
+    $VERSION = '1.23';
     {
        local $SIG{__DIE__};
        eval {
@@ -29,7 +29,7 @@ BEGIN {
 
 
 sub hostname {
-  @_ and warnings::warnif("deprecated", "hostname() doesn't accept any arguments. This will become fatal in Perl 5.32");
+  @_ and croak("hostname() does not accepts arguments (it used to silently discard any provided)");
 
   # method 1 - we already know it
   return $host if defined $host;
index a8c259d..99f9e56 100644 (file)
@@ -10,7 +10,7 @@ BEGIN {
 
 use Sys::Hostname;
 
-use Test::More tests => 4;
+use Test::More tests => 2;
 
 SKIP:
 {
@@ -23,15 +23,10 @@ SKIP:
 }
 
 {
-    use warnings;
-    my $warn;
-    local $SIG{__WARN__} = sub { $warn = "@_" };
-    eval { hostname("dummy") };
-    ok($warn, "warns with an argument");
-    like($warn, qr/hostname\(\) doesn't accept any arguments/,
-         "appropriate message");
-    no warnings "deprecated";
-    undef $warn;
-    eval { hostname("dummy") };
-    is($warn, undef, "no warning when disabled");
+    local $@;
+    eval { hostname("dummy"); };
+    like($@,
+        qr/hostname\(\) does not accepts arguments \(it used to silently discard any provided\)/,
+        "hostname no longer accepts arguments"
+    );
 }