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

ruby-changes:13664

From: matz <ko1@a...>
Date: Sat, 24 Oct 2009 08:37:29 +0900 (JST)
Subject: [ruby-changes:13664] Ruby:r25449 (trunk): * class.c (rb_class_new): move class check to rb_check_inheritable().

matz	2009-10-24 08:37:14 +0900 (Sat, 24 Oct 2009)

  New Revision: 25449

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

  Log:
    * class.c (rb_class_new): move class check to rb_check_inheritable().
    
    * class.c (rb_check_inheritable): should not allow subclass of
      class Class.  [ruby-core:26225]

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/test/ruby/test_class.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25448)
+++ ChangeLog	(revision 25449)
@@ -3,6 +3,13 @@
 	* io.c (io_cntl): update max file descriptor by the result of
 	  fcntl(F_DUPFD).
 
+Fri Oct 23 16:31:14 2009  Yukihiro Matsumoto  <matz@r...>
+
+	* class.c (rb_class_new): move class check to rb_check_inheritable().
+
+	* class.c (rb_check_inheritable): should not allow subclass of
+	  class Class.  [ruby-core:26225]
+
 Fri Oct 23 14:25:54 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (target, target_alias): replace with real cpu.
Index: class.c
===================================================================
--- class.c	(revision 25448)
+++ class.c	(revision 25449)
@@ -97,6 +97,9 @@
     if (RBASIC(super)->flags & FL_SINGLETON) {
 	rb_raise(rb_eTypeError, "can't make subclass of singleton class");
     }
+    if (super == rb_cClass) {
+	rb_raise(rb_eTypeError, "can't make subclass of Class");
+    }
 }
 
 
@@ -111,9 +114,6 @@
 {
     Check_Type(super, T_CLASS);
     rb_check_inheritable(super);
-    if (super == rb_cClass) {
-	rb_raise(rb_eTypeError, "can't make subclass of Class");
-    }
     return rb_class_boot(super);
 }
 
Index: test/ruby/test_class.rb
===================================================================
--- test/ruby/test_class.rb	(revision 25448)
+++ test/ruby/test_class.rb	(revision 25449)
@@ -170,8 +170,7 @@
     o = Object.new
     c = class << o; self; end
     assert_raise(TypeError) { Class.new(c) }
-
-    assert_nothing_raised { Class.new(Class) } # is it OK?
+    assert_raise(TypeError) { Class.new(Class) }
     assert_raise(TypeError) { eval("class Foo < Class; end") }
   end
 

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

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