diff options
author | James E Keenan <jkeenan@cpan.org> | 2019-05-24 22:37:40 -0400 |
---|---|---|
committer | James E Keenan <jkeenan@cpan.org> | 2019-06-04 20:11:24 -0400 |
commit | 82b53111b29b7b8060044482d261a31ccd5ac001 (patch) | |
tree | aface951b0787396579006f2c4dcb09050369c78 /ext/Sys-Hostname | |
parent | 1e420d1cde740938fdfedb4ce5d184e0e29eb093 (diff) | |
download | perl-82b53111b29b7b8060044482d261a31ccd5ac001.tar.gz |
Prevent hostname() from accepting arguments
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
Diffstat (limited to 'ext/Sys-Hostname')
-rw-r--r-- | ext/Sys-Hostname/Hostname.pm | 4 | ||||
-rw-r--r-- | ext/Sys-Hostname/t/Hostname.t | 19 |
2 files changed, 9 insertions, 14 deletions
diff --git a/ext/Sys-Hostname/Hostname.pm b/ext/Sys-Hostname/Hostname.pm index 8b5dde1445..2284e1f81c 100644 --- a/ext/Sys-Hostname/Hostname.pm +++ b/ext/Sys-Hostname/Hostname.pm @@ -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; diff --git a/ext/Sys-Hostname/t/Hostname.t b/ext/Sys-Hostname/t/Hostname.t index a8c259d7c9..99f9e562c7 100644 --- a/ext/Sys-Hostname/t/Hostname.t +++ b/ext/Sys-Hostname/t/Hostname.t @@ -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" + ); } |