summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 03:01:30 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 03:01:30 +0000
commit4450acf4ba10f97b6a5def104dd8c8530fe1ee3d (patch)
tree87cda79b3d534f6f8fca3c26d842a29ba380bd63
parent5b52d585f492bf9929738c27241c028aefebbf2c (diff)
merge revision(s) 56416: [Backport #12836]
* io.c (copy_stream_body): use IO to write to copy to duplex IO. http://twitter.com/knu/status/786505317974585344 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@56569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--io.c2
-rw-r--r--test/ruby/test_io.rb12
-rw-r--r--version.h2
4 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index e09a4056cb..d541062461 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Nov 5 11:53:17 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (copy_stream_body): use IO to write to copy to duplex IO.
+ http://twitter.com/knu/status/786505317974585344
+
Sat Nov 5 11:49:41 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
* sprintf.c (rb_str_format): format exact number more exactly.
diff --git a/io.c b/io.c
index 6f9896462e..3707a69344 100644
--- a/io.c
+++ b/io.c
@@ -10619,7 +10619,7 @@ copy_stream_body(VALUE arg)
else {
VALUE tmp_io = rb_io_check_io(dst_io);
if (!NIL_P(tmp_io)) {
- dst_io = tmp_io;
+ dst_io = GetWriteIO(tmp_io);
}
else if (!RB_TYPE_P(dst_io, T_FILE)) {
VALUE args[3];
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 2b79acea09..c3cf34b799 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1090,6 +1090,18 @@ class TestIO < Test::Unit::TestCase
}
end
+ def test_copy_stream_to_duplex_io
+ result = IO.pipe {|a,w|
+ Thread.start {w.puts "yes"; w.close}
+ IO.popen([EnvUtil.rubybin, '-pe$_="#$.:#$_"'], "r+") {|b|
+ IO.copy_stream(a, b)
+ b.close_write
+ b.read
+ }
+ }
+ assert_equal("1:yes\n", result)
+ end
+
def ruby(*args)
args = ['-e', '$>.write($<.read)'] if args.empty?
ruby = EnvUtil.rubybin
diff --git a/version.h b/version.h
index 4a49f20a95..55dd4f1c56 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.2"
#define RUBY_RELEASE_DATE "2016-11-05"
-#define RUBY_PATCHLEVEL 204
+#define RUBY_PATCHLEVEL 205
#define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 11