[前][次][番号順一覧][スレッド一覧]

ruby-changes:50777

From: normal <ko1@a...>
Date: Wed, 28 Mar 2018 17:38:27 +0900 (JST)
Subject: [ruby-changes:50777] normal:r62967 (trunk): io.c: IO#write without args returns 0

normal	2018-03-28 17:38:21 +0900 (Wed, 28 Mar 2018)

  New Revision: 62967

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62967

  Log:
    io.c: IO#write without args returns 0
    
    This is consistent with other implementations of .write
    in openssl and stringio.
    
    * io.c (io_write_m): return 0 on argc == 0
      [ruby-core:86285] [Bug #14338]

  Modified files:
    trunk/io.c
    trunk/test/ruby/test_io.rb
Index: io.c
===================================================================
--- io.c	(revision 62966)
+++ io.c	(revision 62967)
@@ -1678,7 +1678,7 @@ io_writev(int argc, VALUE *argv, VALUE i https://github.com/ruby/ruby/blob/trunk/io.c#L1678
 static VALUE
 io_write_m(int argc, VALUE *argv, VALUE io)
 {
-    if (argc > 1) {
+    if (argc != 1) {
 	return io_writev(argc, argv, io);
     }
     else {
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 62966)
+++ test/ruby/test_io.rb	(revision 62967)
@@ -1287,6 +1287,13 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1287
     assert_empty(err)
   end
 
+  def test_write_no_args
+    IO.pipe do |r, w|
+      assert_equal 0, w.write, '[ruby-core:86285] [Bug #14338]'
+      assert_equal :wait_readable, r.read_nonblock(1, exception: false)
+    end
+  end
+
   def test_write_non_writable
     with_pipe do |r, w|
       assert_raise(IOError) do

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]