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

ruby-changes:46968

From: nobu <ko1@a...>
Date: Wed, 14 Jun 2017 23:02:40 +0900 (JST)
Subject: [ruby-changes:46968] nobu:r59083 (trunk): proc.c: infect inspect result

nobu	2017-06-14 23:02:33 +0900 (Wed, 14 Jun 2017)

  New Revision: 59083

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

  Log:
    proc.c: infect inspect result
    
    * proc.c (method_inspect): the result should be infected by the
      object.

  Modified files:
    trunk/proc.c
    trunk/test/ruby/test_method.rb
Index: test/ruby/test_method.rb
===================================================================
--- test/ruby/test_method.rb	(revision 59082)
+++ test/ruby/test_method.rb	(revision 59083)
@@ -454,6 +454,9 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L454
     c3.class_eval { alias bar foo }
     m3 = c3.new.method(:bar)
     assert_equal("#<Method: #{c3.inspect}(#{c.inspect})#bar(foo)>", m3.inspect, bug7806)
+
+    m.taint
+    assert_predicate(m.inspect, :tainted?, "inspect result should be infected")
   end
 
   def test_callee_top_level
Index: proc.c
===================================================================
--- proc.c	(revision 59082)
+++ proc.c	(revision 59083)
@@ -2524,6 +2524,7 @@ method_inspect(VALUE method) https://github.com/ruby/ruby/blob/trunk/proc.c#L2524
 
     TypedData_Get_Struct(method, struct METHOD, &method_data_type, data);
     str = rb_str_buf_new2("#<");
+    OBJ_INFECT_RAW(str, method);
     s = rb_obj_classname(method);
     rb_str_buf_cat2(str, s);
     rb_str_buf_cat2(str, ": ");

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

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