ruby-changes:41257
From: normal <ko1@a...>
Date: Sun, 27 Dec 2015 15:15:16 +0900 (JST)
Subject: [ruby-changes:41257] normal:r53329 (trunk): IO#readpartial rejects bad args
normal 2015-12-27 15:15:06 +0900 (Sun, 27 Dec 2015) New Revision: 53329 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53329 Log: IO#readpartial rejects bad args Sometimes a sleepy developer will want to swap read_nonblock for readpartial forget to remove "exception: false" * io.c (io_getpartial): remove unused kwarg from template * test/ruby/test_io.rb (test_readpartial_bad_args): new [Bug #11885] Modified files: trunk/ChangeLog trunk/io.c trunk/test/ruby/test_io.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 53328) +++ ChangeLog (revision 53329) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Dec 27 15:14:20 2015 Eric Wong <e@8...> + + * io.c (io_getpartial): remove unused kwarg from template + * test/ruby/test_io.rb (test_readpartial_bad_args): new + [Bug #11885] + Sun Dec 27 11:50:53 2015 Kuniaki IGARASHI <igaiga@g...> * test/ruby/test_string.rb (test_rstrip, test_lstrip): Add tests Index: io.c =================================================================== --- io.c (revision 53328) +++ io.c (revision 53329) @@ -2506,7 +2506,7 @@ io_getpartial(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/io.c#L2506 long n, len; struct read_internal_arg arg; - rb_scan_args(argc, argv, "11:", &length, &str, NULL); + rb_scan_args(argc, argv, "11", &length, &str); if ((len = NUM2LONG(length)) < 0) { rb_raise(rb_eArgError, "negative length %ld given", len); Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 53328) +++ test/ruby/test_io.rb (revision 53329) @@ -3186,6 +3186,17 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L3186 } end + def test_readpartial_bad_args + IO.pipe do |r, w| + w.write '.' + buf = String.new + assert_raise(ArgumentError) { r.readpartial(1, buf, exception: false) } + assert_raise(TypeError) { r.readpartial(1, exception: false) } + assert_equal [[r],[],[]], IO.select([r], nil, nil, 1) + assert_equal '.', r.readpartial(1) + end + end + def test_sysread_unlocktmp_ensure bug8669 = '[ruby-core:56121] [Bug #8669]' -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/