user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 2/4] avoid relying on IO::Handle/IO::File autoload
Date: Sun, 26 Jan 2020 10:29:22 +0000	[thread overview]
Message-ID: <20200126102924.3593-3-e@yhbt.net> (raw)
In-Reply-To: <20200126102924.3593-1-e@yhbt.net>

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 | 2 +-
 t/httpd-corner.t          | 2 +-
 t/import.t                | 7 +++----
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index 31a1583d..3425e5e4 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -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;
diff --git a/t/httpd-corner.t b/t/httpd-corner.t
index 1f2bb53f..879a023a 100644
--- a/t/httpd-corner.t
+++ b/t/httpd-corner.t
@@ -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 $!;
diff --git a/t/import.t b/t/import.t
index cfbe501b..ecf2c590 100644
--- a/t/import.t
+++ b/t/import.t
@@ -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");
 }

  parent reply	other threads:[~2020-01-26 10:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-26 10:29 [PATCH 0/4] Perl 5.10.1 compatibility fixes Eric Wong
2020-01-26 10:29 ` [PATCH 1/4] daemon: provide TCP_DEFER_ACCEPT for Perl <5.14 Eric Wong
2020-01-26 10:29 ` Eric Wong [this message]
2020-01-26 10:29 ` [PATCH 3/4] t/hl_mod: document IO::Handle for autoflush Eric Wong
2020-01-26 10:29 ` [PATCH 4/4] t/v2reindex.t: 5.10.1 glob compatibility Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200126102924.3593-3-e@yhbt.net \
    --to=e@yhbt.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).