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

ruby-changes:26875

From: marcandre <ko1@a...>
Date: Thu, 24 Jan 2013 16:51:17 +0900 (JST)
Subject: [ruby-changes:26875] marcandRe: r38927 (trunk): * enum.c (enum_zip): Fix error message

marcandre	2013-01-24 16:51:05 +0900 (Thu, 24 Jan 2013)

  New Revision: 38927

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

  Log:
    * enum.c (enum_zip): Fix error message
    
    * array.c (take_items): Same, for Array#zip
      [Bug #7706]

  Modified files:
    trunk/ChangeLog
    trunk/array.c
    trunk/enum.c

Index: array.c
===================================================================
--- array.c	(revision 38926)
+++ array.c	(revision 38927)
@@ -3047,7 +3047,8 @@ take_items(VALUE obj, long n) https://github.com/ruby/ruby/blob/trunk/array.c#L3047
     result = rb_ary_new2(n);
     args[0] = result; args[1] = (VALUE)n;
     if (rb_check_block_call(obj, idEach, 0, 0, take_i, (VALUE)args) == Qundef)
-	Check_Type(obj, T_ARRAY);
+        rb_raise(rb_eTypeError, "wrong argument type %s (must respond to :each)",
+            rb_obj_classname(obj));
     return result;
 }
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38926)
+++ ChangeLog	(revision 38927)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jan 24 16:49:17 2013  Marc-Andre Lafortune  <ruby-core@m...>
+
+	* enum.c (enum_zip): Fix error message
+
+	* array.c (take_items): Same, for Array#zip
+
 Thu Jan 24 16:47:26 2013  Marc-Andre Lafortune  <ruby-core@m...>
 
 	* enumerator.c (lazy_zip): raise error for bad arguments
Index: enum.c
===================================================================
--- enum.c	(revision 38926)
+++ enum.c	(revision 38927)
@@ -2051,7 +2051,10 @@ enum_zip(int argc, VALUE *argv, VALUE ob https://github.com/ruby/ruby/blob/trunk/enum.c#L2051
     if (!allary) {
 	CONST_ID(conv, "to_enum");
 	for (i=0; i<argc; i++) {
-	    if (!rb_respond_to(argv[i], id_each)) Check_Type(argv[i], T_ARRAY);
+	    if (!rb_respond_to(argv[i], id_each)) {
+                rb_raise(rb_eTypeError, "wrong argument type %s (must respond to :each)",
+                    rb_obj_classname(argv[i]));
+            }
 	    argv[i] = rb_funcall(argv[i], conv, 1, ID2SYM(id_each));
 	}
     }

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

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