summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-07 02:41:01 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-07 02:41:01 +0000
commit4169440f382eb85b82ea069e0fd3eca1bcb048fb (patch)
tree16ec9d8ad5a174cc4f779c4b2d3091e92944bd75 /object.c
parentaae187788296ab4f693539479523bcd7168a584a (diff)
* object.c (rb_mod_initialize_clone): Override Kernel#initialize_clone
to avoid an exception on Class.new.freeze.clone.to_s. Reported by Andrew Grimm. [ruby-core:41858] [Bug #5828] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/object.c b/object.c
index 582e2e2..57cbe68 100644
--- a/object.c
+++ b/object.c
@@ -1701,6 +1701,16 @@ rb_mod_initialize(VALUE module)
return Qnil;
}
+static VALUE
+rb_mod_initialize_clone(VALUE clone, VALUE orig)
+{
+ VALUE ret;
+ ret = rb_obj_init_dup_clone(clone, orig);
+ if (OBJ_FROZEN(orig))
+ rb_class_name(clone);
+ return ret;
+}
+
/*
* call-seq:
* Class.new(super_class=Object) -> a_class
@@ -3369,6 +3379,7 @@ Init_Object(void)
rb_define_alloc_func(rb_cModule, rb_module_s_alloc);
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0);
+ rb_define_method(rb_cModule, "initialize_clone", rb_mod_initialize_clone, 1);
rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1); /* in class.c */
rb_define_method(rb_cModule, "public_instance_methods",
rb_class_public_instance_methods, -1); /* in class.c */