diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 2 | ||||
-rw-r--r-- | variable.c | 12 |
3 files changed, 12 insertions, 7 deletions
@@ -1,3 +1,8 @@ +Sat Feb 28 15:02:02 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * variable.c (rb_tmp_class_path): preserve name encoding of an + anonymous instance of module/class subclass. + Sat Feb 28 08:24:30 2015 Rei Odaira <Rei.Odaira@gmail.com> * ext/pty/pty.c: AIX supports autopush. diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index f2694d7b35..d014e8cb05 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1087,6 +1087,8 @@ class TestModule < Test::Unit::TestCase assert_equal("C\u{df}", c.name, '[ruby-core:24600]') c = eval("class C\u{df}; self; end") assert_equal("TestModule::C\u{df}", c.name, '[ruby-core:24600]') + c = Module.new.module_eval("class X\u{df} < Module; self; end") + assert_match(/::X\u{df}:/, c.new.to_s) end def test_method_added diff --git a/variable.c b/variable.c index 9d5ab9f422..f2c574982e 100644 --- a/variable.c +++ b/variable.c @@ -228,21 +228,19 @@ rb_tmp_class_path(VALUE klass, int *permanent, path_cache_func cache_path) return (VALUE)n; } else { - const char *s = "Class"; - if (RB_TYPE_P(klass, T_MODULE)) { if (rb_obj_class(klass) == rb_cModule) { - s = "Module"; + path = rb_sprintf("#<Module:%p>", (void*)klass); } else { int perm; - VALUE path; - path = rb_tmp_class_path(RBASIC(klass)->klass, &perm, cache_path); - s = RSTRING_PTR(path); + path = rb_sprintf("#<%"PRIsVALUE":%p>", path, (void*)klass); } } - path = rb_sprintf("#<%s:%p>", s, (void*)klass); + else { + path = rb_sprintf("#<Class:%p>", (void*)klass); + } OBJ_FREEZE(path); cache_path(klass, tmp_classpath, path); |