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

ruby-changes:37148

From: nobu <ko1@a...>
Date: Tue, 13 Jan 2015 12:48:12 +0900 (JST)
Subject: [ruby-changes:37148] nobu:r49228 (trunk): range.c: class name encoding

nobu	2015-01-13 12:47:55 +0900 (Tue, 13 Jan 2015)

  New Revision: 49228

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

  Log:
    range.c: class name encoding
    
    * range.c (range_bsearch): preserve encoding of class name in an
      exception message.

  Modified files:
    trunk/range.c
    trunk/test/ruby/test_range.rb
Index: range.c
===================================================================
--- range.c	(revision 49227)
+++ range.c	(revision 49228)
@@ -608,9 +608,9 @@ range_bsearch(VALUE range) https://github.com/ruby/ruby/blob/trunk/range.c#L608
 	    smaller = cmp < 0; \
 	} \
 	else { \
-	    rb_raise(rb_eTypeError, "wrong argument type %s" \
-		" (must be numeric, true, false or nil)", \
-		rb_obj_classname(v)); \
+	    rb_raise(rb_eTypeError, "wrong argument type %"PRIsVALUE \
+		     " (must be numeric, true, false or nil)", \
+		     rb_obj_class(v)); \
 	} \
     } while (0)
 
Index: test/ruby/test_range.rb
===================================================================
--- test/ruby/test_range.rb	(revision 49227)
+++ test/ruby/test_range.rb	(revision 49228)
@@ -378,6 +378,10 @@ class TestRange < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_range.rb#L378
     assert_raise(TypeError) do
       (1..42).bsearch{ "not ok" }
     end
+    c = eval("class C\u{309a 26a1 26c4 1f300};self;end")
+    assert_raise_with_message(TypeError, /C\u{309a 26a1 26c4 1f300}/) do
+      (1..42).bsearch {c.new}
+    end
     assert_equal (1..42).bsearch{}, (1..42).bsearch{false}
   end
 

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

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