зеркало из https://github.com/github/ruby.git
variable.c: preserve name encoding of subclass
* variable.c (rb_tmp_class_path): preserve name encoding of an anonymous instance of module/class subclass. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
0066608c13
Коммит
1ef1a0c602
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
12
variable.c
12
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче