ruby-changes:35138
From: nobu <ko1@a...>
Date: Tue, 19 Aug 2014 13:59:51 +0900 (JST)
Subject: [ruby-changes:35138] nobu:r47220 (trunk): compar.c: preserve encodings
nobu 2014-08-19 13:59:44 +0900 (Tue, 19 Aug 2014) New Revision: 47220 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47220 Log: compar.c: preserve encodings * compar.c (rb_cmperr): preserve encodings of arguments in the message. Modified files: trunk/ChangeLog trunk/compar.c trunk/test/ruby/test_comparable.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 47219) +++ ChangeLog (revision 47220) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Aug 19 13:59:43 2014 Nobuyoshi Nakada <nobu@r...> + + * compar.c (rb_cmperr): preserve encodings of arguments in the + message. + Tue Aug 19 10:13:23 2014 Nobuyoshi Nakada <nobu@r...> * ext/thread/thread.c (get_array): check instance variables are Index: compar.c =================================================================== --- compar.c (revision 47219) +++ compar.c (revision 47220) @@ -18,17 +18,16 @@ static ID cmp; https://github.com/ruby/ruby/blob/trunk/compar.c#L18 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 Index: test/ruby/test_comparable.rb =================================================================== --- test/ruby/test_comparable.rb (revision 47219) +++ test/ruby/test_comparable.rb (revision 47220) @@ -73,6 +73,10 @@ class TestComparable < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_comparable.rb#L73 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/