aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-27 06:15:06 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-27 06:15:06 +0000
commitdc44988fa24b429cf0f73574a5eff5a73a335c56 (patch)
treeaed0feb8463d3e50a334b08d87dcf44c600d48a3
parent7b84c1ea0ab8e0e4f562d8f415962a22ce31944c (diff)
downloadruby-dc44988fa24b429cf0f73574a5eff5a73a335c56.tar.gz
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--io.c2
-rw-r--r--test/ruby/test_io.rb11
3 files changed, 18 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a1d9c73c9..8358b855bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Dec 27 15:14:20 2015 Eric Wong <e@80x24.org>
+
+ * 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@gmail.com>
* test/ruby/test_string.rb (test_rstrip, test_lstrip): Add tests
diff --git a/io.c b/io.c
index 2bf7cd7512..5c8a66d143 100644
--- a/io.c
+++ b/io.c
@@ -2506,7 +2506,7 @@ io_getpartial(int argc, VALUE *argv, VALUE io, VALUE opts, int nonblock)
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);
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 766804eb2e..2b79acea09 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -3186,6 +3186,17 @@ End
}
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]'