range.c: class name encoding

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-01-13 03:47:55 +00:00
parent 225e3b011f
commit 6b8b66b401
2 changed files with 7 additions and 3 deletions

View File

@ -608,9 +608,9 @@ range_bsearch(VALUE range)
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)

View File

@ -378,6 +378,10 @@ class TestRange < Test::Unit::TestCase
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