summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-22 13:04:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-22 13:04:38 +0000
commit35bf8099d4dc06437e816815ad38309e68628d26 (patch)
tree0d46521c5295ea054311e1b16670da8983ff9115
parentfa1a2ae15852ff5f3826a6173effe4d624ab8d72 (diff)
merge revision(s) 34735,34736:
* io.c (rb_io_s_foreach): return enumerator including kerword arguments. [ruby-dev:45267][Bug #6054] * io.c (rb_io_s_foreach): argument check before making Enumerator. [ruby-dev:31525] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--io.c3
-rw-r--r--test/ruby/test_io.rb10
-rw-r--r--version.h2
4 files changed, 23 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index e98a4ff34a..a8c35bbc28 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Wed Feb 22 22:04:15 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (rb_io_s_foreach): argument check before making Enumerator.
+ [ruby-dev:31525]
+
+Wed Feb 22 22:04:15 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (rb_io_s_foreach): return enumerator including kerword
+ arguments. [ruby-dev:45267][Bug #6054]
+
Wed Feb 22 21:42:16 2012 NARUSE, Yui <naruse@ruby-lang.org>
* configure.in: remove workaround replacement from gcc to gcc-4.2.
diff --git a/io.c b/io.c
index 1e8fb95c61..178859ee6d 100644
--- a/io.c
+++ b/io.c
@@ -8484,10 +8484,11 @@ static VALUE
rb_io_s_foreach(int argc, VALUE *argv, VALUE self)
{
VALUE opt;
+ int orig_argc = argc;
struct foreach_arg arg;
argc = rb_scan_args(argc, argv, "13:", NULL, NULL, NULL, NULL, &opt);
- RETURN_ENUMERATOR(self, argc, argv);
+ RETURN_ENUMERATOR(self, orig_argc, argv);
open_key_args(argc, argv, opt, &arg);
if (NIL_P(arg.io)) return Qnil;
return rb_ensure(io_s_foreach, (VALUE)&arg, rb_io_close, arg.io);
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 0fb28071cc..bb6f239509 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1555,6 +1555,16 @@ End
IO.foreach(t.path, "b", 3) {|x| a << x }
assert_equal(["foo", "\nb", "ar\n", "b", "az\n"], a)
+ bug = '[ruby-dev:31525]'
+ assert_raise(ArgumentError, bug) {IO.foreach}
+
+ a = nil
+ assert_nothing_raised(ArgumentError, bug) {a = IO.foreach(t.path).to_a}
+ assert_equal(["foo\n", "bar\n", "baz\n"], a, bug)
+
+ bug6054 = '[ruby-dev:45267]'
+ e = assert_raise(IOError, bug6054) {IO.foreach(t.path, mode:"w").next}
+ assert_match(/not opened for reading/, e.message, bug6054)
end
def test_s_readlines
diff --git a/version.h b/version.h
index c1353e2cb4..fd1c70d179 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 137
+#define RUBY_PATCHLEVEL 138
#define RUBY_RELEASE_DATE "2012-02-22"
#define RUBY_RELEASE_YEAR 2012