Skip to content

Commit

Permalink
* class.c (rb_class_init_copy): raise a TypeError if the argument is
Browse files Browse the repository at this point in the history
  BasicObject.  [ruby-core:27060]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
shugo committed Feb 6, 2010
1 parent 666964f commit 6ea0e49
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
Sun Feb 7 00:23:21 2010 Shugo Maeda <shugo@ruby-lang.org>

* class.c (rb_class_init_copy): raise a TypeError if the argument is
BasicObject. [ruby-core:27060]

Sat Feb 6 23:37:11 2010 Shugo Maeda <shugo@ruby-lang.org>

* lib/net/ftp.rb (initialize): set @sock to a NullSocket instance to
Expand Down
3 changes: 3 additions & 0 deletions class.c
Expand Up @@ -180,6 +180,9 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
VALUE
rb_class_init_copy(VALUE clone, VALUE orig)
{
if (orig == rb_cBasicObject) {
rb_raise(rb_eTypeError, "can't copy the root class");
}
if (RCLASS_SUPER(clone) != 0 || clone == rb_cBasicObject) {
rb_raise(rb_eTypeError, "already initialized class");
}
Expand Down
2 changes: 2 additions & 0 deletions test/ruby/test_class.rb
Expand Up @@ -181,6 +181,8 @@ def test_initialize_copy
o = Object.new
c = class << o; self; end
assert_raise(TypeError) { c.dup }

assert_raise(TypeError) { BasicObject.dup }
end

def test_singleton_class
Expand Down

0 comments on commit 6ea0e49

Please sign in to comment.