Skip to content

Commit 82b5311

Browse files
committed
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
1 parent 1e420d1 commit 82b5311

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

ext/Sys-Hostname/Hostname.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use warnings ();
1616
our $host;
1717

1818
BEGIN {
19-
$VERSION = '1.22';
19+
$VERSION = '1.23';
2020
{
2121
local $SIG{__DIE__};
2222
eval {
@@ -29,7 +29,7 @@ BEGIN {
2929

3030

3131
sub hostname {
32-
@_ and warnings::warnif("deprecated", "hostname() doesn't accept any arguments. This will become fatal in Perl 5.32");
32+
@_ and croak("hostname() does not accepts arguments (it used to silently discard any provided)");
3333

3434
# method 1 - we already know it
3535
return $host if defined $host;

ext/Sys-Hostname/t/Hostname.t

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ BEGIN {
1010

1111
use Sys::Hostname;
1212

13-
use Test::More tests => 4;
13+
use Test::More tests => 2;
1414

1515
SKIP:
1616
{
@@ -23,15 +23,10 @@ SKIP:
2323
}
2424

2525
{
26-
use warnings;
27-
my $warn;
28-
local $SIG{__WARN__} = sub { $warn = "@_" };
29-
eval { hostname("dummy") };
30-
ok($warn, "warns with an argument");
31-
like($warn, qr/hostname\(\) doesn't accept any arguments/,
32-
"appropriate message");
33-
no warnings "deprecated";
34-
undef $warn;
35-
eval { hostname("dummy") };
36-
is($warn, undef, "no warning when disabled");
26+
local $@;
27+
eval { hostname("dummy"); };
28+
like($@,
29+
qr/hostname\(\) does not accepts arguments \(it used to silently discard any provided\)/,
30+
"hostname no longer accepts arguments"
31+
);
3732
}

0 commit comments

Comments
 (0)