summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--compar.c11
-rw-r--r--test/ruby/test_comparable.rb4
3 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index aea3500cb5..837062f7d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Aug 19 13:59:43 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * compar.c (rb_cmperr): preserve encodings of arguments in the
+ message.
+
Tue Aug 19 10:13:23 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/thread/thread.c (get_array): check instance variables are
diff --git a/compar.c b/compar.c
index 893cde79fc..a38668edf1 100644
--- a/compar.c
+++ b/compar.c
@@ -18,17 +18,16 @@ static ID cmp;
void
rb_cmperr(VALUE x, VALUE y)
{
- const char *classname;
+ VALUE classname;
if (SPECIAL_CONST_P(y)) {
- y = rb_inspect(y);
- classname = StringValuePtr(y);
+ classname = rb_inspect(y);
}
else {
- classname = rb_obj_classname(y);
+ classname = rb_class_path(rb_obj_class(y));
}
- rb_raise(rb_eArgError, "comparison of %s with %s failed",
- rb_obj_classname(x), classname);
+ rb_raise(rb_eArgError, "comparison of %"PRIsVALUE" with %"PRIsVALUE" failed",
+ rb_class_path(rb_obj_class(x)), classname);
}
static VALUE
diff --git a/test/ruby/test_comparable.rb b/test/ruby/test_comparable.rb
index 05426af139..1c3cbeaf1a 100644
--- a/test/ruby/test_comparable.rb
+++ b/test/ruby/test_comparable.rb
@@ -73,6 +73,10 @@ class TestComparable < Test::Unit::TestCase
def test_err
assert_raise(ArgumentError) { 1.0 < nil }
assert_raise(ArgumentError) { 1.0 < Object.new }
+ e = Module.new {break module_eval("class E\u{30a8 30e9 30fc}; self; end")}
+ assert_raise_with_message(ArgumentError, /E\u{30a8 30e9 30fc}/) {
+ 1.0 < e.new
+ }
end
def test_inversed_compare