]> Sergey Matveev's repositories - public-inbox.git/commitdiff
avoid relying on IO::Handle/IO::File autoload
authorEric Wong <e@yhbt.net>
Sun, 26 Jan 2020 10:29:22 +0000 (10:29 +0000)
committerEric Wong <e@yhbt.net>
Tue, 28 Jan 2020 01:49:50 +0000 (01:49 +0000)
Perl 5.14+ gained the ability to autoload IO::File
(and IO::Handle) on missing methods, so relying on
this breaks under 5.10.1.

There's no reason to load IO::File or IO::Handle
when built-in perlops work fine and are even a hair
faster.

lib/PublicInbox/Qspawn.pm
t/httpd-corner.t
t/import.t

index 31a1583dfebcef7d6f9a25749493f63fce563f9a..3425e5e4558ba3911d0979ab01ea534c47434f86 100644 (file)
@@ -164,7 +164,7 @@ reread:
                $async->async_pass($self->{psgi_env}->{'psgix.io'},
                                        $qx_fh, \$buf);
        } elsif (defined $r) {
-               $r ? $qx_fh->write($buf) : event_step($self, undef);
+               $r ? (print $qx_fh $buf) : event_step($self, undef);
        } else {
                return if $! == EAGAIN; # try again when notified
                goto reread if $! == EINTR;
index 1f2bb53f7b932afacaedf22fca57ee871335d973..879a023a1dca4fccb336a23eb7c8a0347559b320 100644 (file)
@@ -278,7 +278,7 @@ SKIP: {
        waitpid($pid, 0);
        is($?, 0, 'curl exited successfully');
        is(-s $cerr, 0, 'no errors from curl');
-       $cout->seek(0, SEEK_SET);
+       seek($cout, 0, SEEK_SET);
        is(<$cout>, sha1_hex($str), 'read expected body');
 
        open my $fh, '-|', qw(curl -sS), "$base/async-big" or die $!;
index cfbe501b102bca5061856ac52609529ed650c37e..ecf2c5906854a514e694768efc7e94e97dac49a8 100644 (file)
@@ -7,8 +7,7 @@ use PublicInbox::MIME;
 use PublicInbox::Git;
 use PublicInbox::Import;
 use PublicInbox::Spawn qw(spawn);
-use IO::File;
-use Fcntl qw(:DEFAULT);
+use Fcntl qw(:DEFAULT SEEK_SET);
 use File::Temp qw/tempfile/;
 use PublicInbox::TestCommon;
 my ($dir, $for_destroy) = tmpdir();
@@ -42,12 +41,12 @@ if ($v2) {
        my $in = tempfile();
        print $in $mime->as_string or die "write failed: $!";
        $in->flush or die "flush failed: $!";
-       $in->seek(0, SEEK_SET);
+       seek($in, 0, SEEK_SET);
        my $out = tempfile();
        my $pid = spawn(\@cmd, {}, { 0 => $in, 1 => $out });
        is(waitpid($pid, 0), $pid, 'waitpid succeeds on hash-object');
        is($?, 0, 'hash-object');
-       $out->seek(0, SEEK_SET);
+       seek($out, 0, SEEK_SET);
        chomp(my $hashed_obj = <$out>);
        is($hashed_obj, $info->[0], "last object_id matches exp");
 }