[前][次][番号順一覧][スレッド一覧]

ruby-changes:37697

From: nobu <ko1@a...>
Date: Sat, 28 Feb 2015 15:02:21 +0900 (JST)
Subject: [ruby-changes:37697] nobu:r49778 (trunk): variable.c: preserve name encoding of subclass

nobu	2015-02-28 15:02:06 +0900 (Sat, 28 Feb 2015)

  New Revision: 49778

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49778

  Log:
    variable.c: preserve name encoding of subclass
    
    * variable.c (rb_tmp_class_path): preserve name encoding of an
      anonymous instance of module/class subclass.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_module.rb
    trunk/variable.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49777)
+++ ChangeLog	(revision 49778)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Feb 28 15:02:02 2015  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@g...>
 
 	* ext/pty/pty.c: AIX supports autopush.
Index: variable.c
===================================================================
--- variable.c	(revision 49777)
+++ variable.c	(revision 49778)
@@ -228,21 +228,19 @@ rb_tmp_class_path(VALUE klass, int *perm https://github.com/ruby/ruby/blob/trunk/variable.c#L228
 	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);
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 49777)
+++ test/ruby/test_module.rb	(revision 49778)
@@ -1087,6 +1087,8 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1087
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]