ruby-changes:34054
From: nobu <ko1@a...>
Date: Mon, 26 May 2014 16:00:16 +0900 (JST)
Subject: [ruby-changes:34054] nobu:r46135 (trunk): thread.c: preserve encoding
nobu 2014-05-26 16:00:02 +0900 (Mon, 26 May 2014) New Revision: 46135 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=46135 Log: thread.c: preserve encoding * thread.c (rb_thread_inspect): preserve encoding of the class name. Modified files: trunk/test/ruby/test_thread.rb trunk/thread.c Index: thread.c =================================================================== --- thread.c (revision 46134) +++ thread.c (revision 46135) @@ -2679,14 +2679,14 @@ rb_thread_safe_level(VALUE thread) https://github.com/ruby/ruby/blob/trunk/thread.c#L2679 static VALUE rb_thread_inspect(VALUE thread) { - const char *cname = rb_obj_classname(thread); + VALUE cname = rb_class_path(rb_obj_class(thread)); rb_thread_t *th; const char *status; VALUE str; GetThreadPtr(thread, th); status = thread_status_name(th); - str = rb_sprintf("#<%s:%p %s>", cname, (void *)thread, status); + str = rb_sprintf("#<%"PRIsVALUE":%p %s>", cname, (void *)thread, status); OBJ_INFECT(str, thread); return str; Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 46134) +++ test/ruby/test_thread.rb (revision 46135) @@ -27,6 +27,13 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L27 end end + def test_inspect + th = Module.new {break module_eval("class C\u{30b9 30ec 30c3 30c9} < Thread; self; end")}.start{} + assert_match(/::C\u{30b9 30ec 30c3 30c9}:/, th.inspect) + ensure + th.join + end + def test_main_thread_variable_in_enumerator assert_equal Thread.main, Thread.current -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/