summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--io.c4
-rw-r--r--test/ruby/test_io.rb3
2 files changed, 5 insertions, 2 deletions
diff --git a/io.c b/io.c
index f75c8aee95..d403df399c 100644
--- a/io.c
+++ b/io.c
@@ -11400,7 +11400,7 @@ rb_io_s_foreach(int argc, VALUE *argv, VALUE self)
struct foreach_arg arg;
struct getline_arg garg;
- argc = rb_scan_args(argc, argv, "13:", NULL, NULL, NULL, NULL, &opt);
+ argc = rb_scan_args(argc, argv, "12:", NULL, NULL, NULL, &opt);
RETURN_ENUMERATOR(self, orig_argc, argv);
extract_getline_args(argc-1, argv+1, &garg);
open_key_args(self, argc, argv, opt, &arg);
@@ -11495,7 +11495,7 @@ rb_io_s_readlines(int argc, VALUE *argv, VALUE io)
struct foreach_arg arg;
struct getline_arg garg;
- argc = rb_scan_args(argc, argv, "13:", NULL, NULL, NULL, NULL, &opt);
+ argc = rb_scan_args(argc, argv, "12:", NULL, NULL, NULL, &opt);
extract_getline_args(argc-1, argv+1, &garg);
open_key_args(io, argc, argv, opt, &arg);
if (NIL_P(arg.io)) return Qnil;
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index ed0198321d..0f42d8e164 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2596,6 +2596,8 @@ class TestIO < Test::Unit::TestCase
assert_raise_with_message(IOError, /not opened for reading/, bug6054) do
IO.foreach(t.path, mode:"w").next
end
+
+ assert_raise(ArgumentError, "[Bug #18771] [ruby-core:108503]") {IO.foreach(t, "\n", 10, true){}}
}
end
@@ -2605,6 +2607,7 @@ class TestIO < Test::Unit::TestCase
assert_equal(["foo\nb", "ar\nb", "az\n"], IO.readlines(t.path, "b"))
assert_equal(["fo", "o\n", "ba", "r\n", "ba", "z\n"], IO.readlines(t.path, 2))
assert_equal(["fo", "o\n", "b", "ar", "\nb", "az", "\n"], IO.readlines(t.path, "b", 2))
+ assert_raise(ArgumentError, "[Bug #18771] [ruby-core:108503]") {IO.readlines(t, "\n", 10, true){}}
}
end