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

ruby-changes:44160

From: nagachika <ko1@a...>
Date: Sun, 25 Sep 2016 16:36:12 +0900 (JST)
Subject: [ruby-changes:44160] nagachika:r56233 (ruby_2_3): merge revision(s) 56111: [Backport #12738]

nagachika	2016-09-25 16:36:06 +0900 (Sun, 25 Sep 2016)

  New Revision: 56233

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

  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_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/array.c
    branches/ruby_2_3/test/ruby/test_array.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 56232)
+++ ruby_2_3/version.h	(revision 56233)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.2"
 #define RUBY_RELEASE_DATE "2016-09-25"
-#define RUBY_PATCHLEVEL 183
+#define RUBY_PATCHLEVEL 184
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 9
Index: ruby_2_3/test/ruby/test_array.rb
===================================================================
--- ruby_2_3/test/ruby/test_array.rb	(revision 56232)
+++ ruby_2_3/test/ruby/test_array.rb	(revision 56233)
@@ -805,6 +805,15 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_array.rb#L805
     assert_nothing_raised(RuntimeError, bug10748) {a.flatten(1)}
   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 ]
@@ -842,6 +851,15 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_array.rb#L851
     assert_nothing_raised(RuntimeError, bug10748) {a.flatten!(1)}
   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_3/array.c
===================================================================
--- ruby_2_3/array.c	(revision 56232)
+++ ruby_2_3/array.c	(revision 56233)
@@ -4461,7 +4461,7 @@ flatten(VALUE ary, int level, int *modif https://github.com/ruby/ruby/blob/trunk/ruby_2_3/array.c#L4461
 
     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_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 56232)
+++ ruby_2_3/ChangeLog	(revision 56233)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Sun Sep 25 15:09:04 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]
+
 Sun Sep 25 15:07:19 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* man/irb.1: remove useless -width option.

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


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

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