]> Sergey Matveev's repositories - public-inbox.git/commitdiff
spamcheck/spamc: fix compatibility with Perl 5.14.2
authorEric Wong <e@80x24.org>
Sun, 26 Jun 2016 07:58:43 +0000 (07:58 +0000)
committerEric Wong <e@80x24.org>
Sun, 26 Jun 2016 07:58:43 +0000 (07:58 +0000)
This is necessary for Debian 7.x (wheezy), since
GLOB objects do not seem responsive to the can("fileno")
check (we do a similar check in GitHTTPBackend).

lib/PublicInbox/Spamcheck/Spamc.pm

index 312e52df92fd454274ed0fdf621b71a834b69dfa..5190c269285473a514a93b861e74302f3fc530d2 100644 (file)
@@ -75,8 +75,8 @@ sub _msg_to_fd {
        my $tmpfh;
        my $fd;
        if (my $ref = ref($msg)) {
-
-               return $msg->fileno if $ref ne 'SCALAR' && $msg->can('fileno');
+               my $fileno = eval { fileno($msg) };
+               return $fileno if defined $fileno;
 
                $tmpfh = IO::File->new_tmpfile;
                $tmpfh->autoflush(1);