ruby-changes:45606
From: nobu <ko1@a...>
Date: Tue, 21 Feb 2017 23:51:26 +0900 (JST)
Subject: [ruby-changes:45606] nobu:r57679 (trunk): object.c: message encoding
nobu 2017-02-21 23:51:22 +0900 (Tue, 21 Feb 2017) New Revision: 57679 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57679 Log: object.c: message encoding * object.c (rb_obj_clone2): preserve encoding in error messages. Modified files: trunk/object.c trunk/test/ruby/test_object.rb Index: object.c =================================================================== --- object.c (revision 57678) +++ object.c (revision 57679) @@ -354,14 +354,15 @@ rb_obj_clone2(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/object.c#L354 rb_get_kwargs(opt, keyword_ids, 0, 1, kwargs); kwfreeze = kwargs[0]; if (kwfreeze != Qundef && kwfreeze != Qtrue && kwfreeze != Qfalse) { - rb_raise(rb_eArgError, "unexpected value for freeze: %s", - rb_builtin_class_name(kwfreeze)); + rb_raise(rb_eArgError, "unexpected value for freeze: %"PRIsVALUE, + rb_obj_class(kwfreeze)); } } if (special_object_p(obj)) { if (kwfreeze == Qfalse) - rb_raise(rb_eArgError, "can't unfreeze %s", rb_obj_classname(obj)); + rb_raise(rb_eArgError, "can't unfreeze %"PRIsVALUE, + rb_obj_class(obj)); return obj; } clone = rb_obj_alloc(rb_obj_class(obj)); Index: test/ruby/test_object.rb =================================================================== --- test/ruby/test_object.rb (revision 57678) +++ test/ruby/test_object.rb (revision 57679) @@ -61,6 +61,10 @@ class TestObject < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_object.rb#L61 assert_raise(ArgumentError) {true.clone(freeze: false)} assert_raise(ArgumentError) {nil.clone(freeze: false)} assert_raise(ArgumentError) {false.clone(freeze: false)} + x = EnvUtil.labeled_class("\u{1f4a9}").new + assert_raise_with_message(ArgumentError, /\u{1f4a9}/) do + Object.new.clone(freeze: x) + end end def test_init_dupclone -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/