summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-25 18:58:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-25 18:58:05 +0000
commit91e2cd34d4a8f8bd624a7fcd25c34239c8e3b319 (patch)
treecb1350068e0877b89fcab30dd7cf46a72651113c
parent606e855622c2694c6bf1a5cec59373bef0d0877e (diff)
vm_method.c: preserve encodings
* vm_method.c (rb_mod_remove_method): preserve encodings of method name and class name in error messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_object.rb13
-rw-r--r--vm_method.c4
2 files changed, 15 insertions, 2 deletions
diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb
index 94a6e9d..a1514ed 100644
--- a/test/ruby/test_object.rb
+++ b/test/ruby/test_object.rb
@@ -365,6 +365,19 @@ class TestObject < Test::Unit::TestCase
end
INPUT
end
+
+ m = "\u{30e1 30bd 30c3 30c9}"
+ c = Class.new
+ assert_raise_with_message(NameError, /#{m}/) do
+ c.class_eval {remove_method m}
+ end
+ c = Class.new {
+ define_method(m) {}
+ remove_method(m)
+ }
+ assert_raise_with_message(NameError, /#{m}/) do
+ c.class_eval {remove_method m}
+ end
end
def test_method_missing
diff --git a/vm_method.c b/vm_method.c
index 1f397e3..8af2198 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -806,8 +806,8 @@ rb_mod_remove_method(int argc, VALUE *argv, VALUE mod)
VALUE v = argv[i];
ID id = rb_check_id(&v);
if (!id) {
- rb_name_error_str(v, "method `%s' not defined in %s",
- RSTRING_PTR(v), rb_class2name(mod));
+ rb_name_error_str(v, "method `%"PRIsVALUE"' not defined in %"PRIsVALUE,
+ v, rb_obj_class(mod));
}
remove_method(mod, id);
}