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

ruby-changes:72110

From: Jeremy <ko1@a...>
Date: Fri, 10 Jun 2022 00:22:23 +0900 (JST)
Subject: [ruby-changes:72110] 27eb36596a (master): Stop ignoring 4th positional argument to IO.#{foreach, readlines}

https://git.ruby-lang.org/ruby.git/commit/?id=27eb36596a

From 27eb36596a65d6bca44b4420ca6526175bf1b431 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Thu, 26 May 2022 10:45:36 -0700
Subject: Stop ignoring 4th positional argument to IO.#{foreach,readlines}

Fixes [Bug #18771]
---
 io.c                 | 4 ++--
 test/ruby/test_io.rb | 3 +++
 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) https://github.com/ruby/ruby/blob/trunk/io.c#L11400
     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) https://github.com/ruby/ruby/blob/trunk/io.c#L11495
     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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2596
       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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2607
       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
 
-- 
cgit v1.2.1


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

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