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

ruby-changes:44232

From: usa <ko1@a...>
Date: Sat, 1 Oct 2016 00:54:21 +0900 (JST)
Subject: [ruby-changes:44232] usa:r56305 (ruby_2_2): merge revision(s) 56111: [Backport #12738]

usa	2016-10-01 00:54:16 +0900 (Sat, 01 Oct 2016)

  New Revision: 56305

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

  Log:
    merge revision(s) 56111: [Backport #12738]
    
    * array.c (flatten): use rb_obj_class instead of rb_class_of
      because rb_class_of may return a singleton class.
      [ruby-dev:49781] [Bug #12738]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/array.c
    branches/ruby_2_2/test/ruby/test_array.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/array.c
===================================================================
--- ruby_2_2/array.c	(revision 56304)
+++ ruby_2_2/array.c	(revision 56305)
@@ -4383,7 +4383,7 @@ flatten(VALUE ary, int level, int *modif https://github.com/ruby/ruby/blob/trunk/ruby_2_2/array.c#L4383
 
     st_free_table(memo);
 
-    RBASIC_SET_CLASS(result, rb_class_of(ary));
+    RBASIC_SET_CLASS(result, rb_obj_class(ary));
     return result;
 }
 
Index: ruby_2_2/test/ruby/test_array.rb
===================================================================
--- ruby_2_2/test/ruby/test_array.rb	(revision 56304)
+++ ruby_2_2/test/ruby/test_array.rb	(revision 56305)
@@ -784,6 +784,15 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_array.rb#L784
     assert_not_same(a8, a9)
   end
 
+  def test_flattern_singleton_class
+    bug12738 = '[ruby-dev:49781] [Bug #12738]'
+    a = [[0]]
+    class << a
+      def m; end
+    end
+    assert_raise(NoMethodError, bug12738) { a.flatten.m }
+  end
+
   def test_flatten!
     a1 = @cls[ 1, 2, 3]
     a2 = @cls[ 5, 6 ]
@@ -804,6 +813,15 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_array.rb#L813
     assert_nil(@cls[].flatten!(0), '[ruby-core:23382]')
   end
 
+  def test_flattern_singleton_class!
+    bug12738 = '[ruby-dev:49781] [Bug #12738]'
+    a = [[0]]
+    class << a
+      def m; end
+    end
+    assert_nothing_raised(NameError, bug12738) { a.flatten!.m }
+  end
+
   def test_flatten_with_callcc
     need_continuation
     o = Object.new
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 56304)
+++ ruby_2_2/version.h	(revision 56305)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.6"
 #define RUBY_RELEASE_DATE "2016-10-01"
-#define RUBY_PATCHLEVEL 374
+#define RUBY_PATCHLEVEL 375
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 10
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 56304)
+++ ruby_2_2/ChangeLog	(revision 56305)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Sat Oct  1 00:53:28 2016  Kazuki Tsujimoto  <kazuki@c...>
+
+	* array.c (flatten): use rb_obj_class instead of rb_class_of
+	  because rb_class_of may return a singleton class.
+	  [ruby-dev:49781] [Bug #12738]
+
 Sat Oct  1 00:52:34 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* man/irb.1: remove useless -width option.

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r56111


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

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