ruby-changes:37134
From: nobu <ko1@a...>
Date: Mon, 12 Jan 2015 08:48:21 +0900 (JST)
Subject: [ruby-changes:37134] nobu:r49215 (trunk): array.c: class name encoding
nobu 2015-01-12 08:48:10 +0900 (Mon, 12 Jan 2015) New Revision: 49215 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49215 Log: array.c: class name encoding * array.c (rb_ary_bsearch): preserve encoding of class name in an exception message. Modified files: trunk/array.c trunk/test/ruby/test_array.rb Index: array.c =================================================================== --- array.c (revision 49214) +++ array.c (revision 49215) @@ -2615,15 +2615,15 @@ rb_ary_bsearch(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L2615 else if (rb_obj_is_kind_of(v, rb_cNumeric)) { const VALUE zero = INT2FIX(0); switch (rb_cmpint(rb_funcallv(v, id_cmp, 1, &zero), v, INT2FIX(0))) { - case 0: return val; - case 1: smaller = 1; break; - case -1: smaller = 0; + case 0: return val; + case 1: smaller = 1; break; + case -1: smaller = 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)); } if (smaller) { high = mid; Index: test/ruby/test_array.rb =================================================================== --- test/ruby/test_array.rb (revision 49214) +++ test/ruby/test_array.rb (revision 49215) @@ -2458,6 +2458,10 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L2458 assert_raise(TypeError) do [1, 2, 42, 100, 666].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 + [0,1].bsearch {c.new} + end assert_equal [1, 2, 42, 100, 666].bsearch{}, [1, 2, 42, 100, 666].bsearch{false} end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/