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

ruby-changes:32165

From: nobu <ko1@a...>
Date: Mon, 16 Dec 2013 19:25:34 +0900 (JST)
Subject: [ruby-changes:32165] nobu:r44244 (trunk): class.c: fix option hash

nobu	2013-12-16 19:25:21 +0900 (Mon, 16 Dec 2013)

  New Revision: 44244

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44244

  Log:
    class.c: fix option hash
    
    * class.c (rb_scan_args): if no keywords is given return nil as
      the option hash.

  Modified files:
    trunk/class.c
    trunk/test/ruby/test_io.rb
Index: class.c
===================================================================
--- class.c	(revision 44243)
+++ class.c	(revision 44244)
@@ -1788,7 +1788,7 @@ rb_scan_args(int argc, const VALUE *argv https://github.com/ruby/ruby/blob/trunk/class.c#L1788
 	    if (!NIL_P(hash)) {
 		VALUE opts = rb_extract_keywords(&hash);
 		if (!hash) argc--;
-		hash = opts;
+		hash = opts ? opts : Qnil;
 	    }
 	}
     }
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 44243)
+++ test/ruby/test_io.rb	(revision 44244)
@@ -2981,6 +2981,9 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2981
     File.unlink(path)
     IO.write(path, "foo", encoding: Encoding::UTF_32BE)
     assert_equal("\0\0\0f\0\0\0o\0\0\0o", File.binread(path))
+    assert_raise(TypeError) {
+      IO.write(path, "foo", Object.new => Object.new)
+    }
   ensure
     t.close!
   end

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

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