Feature #2470: Encoding#new doesn’t undef_method-ed
http://redmine.ruby-lang.org/issues/show/2470
e$B5/I<<Te(B: Yui NARUSE
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$B%+%F%4%je(B: core
Fixnum e$B$de(B Encoding e$B$N$h$&$J!"e(Brb_undef_alloc_func
e$B$5$l$F$$$k%/%i%9$G$O!"e(B
Hoge.new e$B$,%(%i!<$K$J$j$^$9$,!"e(B
Fixnum e$B$J$I$G$Oe(B Fixnum.new e$B$,e(B undef e$B$5$l$F$$$k$N$K!"e(B
Encoding e$B$G$O$J$5$l$F$$$J$$$?$a!"8F$s$@:]$N5sF0$,0[$J$j$^$9!#e(B
irb(main):001:0> Fixnum.new
NoMethodError: undefined method new' for Fixnum:Class from (irb):1 from /usr/local/bin/irb_1_9_1:12:in
’
irb(main):002:0> Encoding.new
TypeError: allocator undefined for Encoding
from (irb):2:in new' from (irb):2 from /usr/local/bin/irb_1_9_1:12:in
’
e$B0J2<$,%Q%C%A$G$9!#e(B
diff --git a/encoding.c b/encoding.c
index 38d81b8…f9d2f20 100644
— a/encoding.c
+++ b/encoding.c
@@ -1484,6 +1484,7 @@ Init_Encoding(void)
rb_cEncoding = rb_define_class("Encoding", rb_cObject);
rb_undef_alloc_func(rb_cEncoding);
-
rb_undef_method(CLASS_OF(rb_cEncoding), “new”);
rb_define_method(rb_cEncoding, “to_s”, enc_name, 0);
rb_define_method(rb_cEncoding, “inspect”, enc_inspect, 0);
rb_define_method(rb_cEncoding, “name”, enc_name, 0);
diff --git a/object.c b/object.c
index 10eb983…704cb2a 100644
— a/object.c
+++ b/object.c
@@ -2680,6 +2680,7 @@ Init_Object(void)rb_cData = rb_define_class(“Data”, rb_cObject);
rb_undef_alloc_func(rb_cData); -
rb_undef_method(CLASS_OF(rb_cData), “new”);
rb_cTrueClass = rb_define_class(“TrueClass”, rb_cObject);
rb_define_method(rb_cTrueClass, “to_s”, true_to_s, 0);
diff --git a/vm.c b/vm.c
index fa028fd…e522c9f 100644
— a/vm.c
+++ b/vm.c
@@ -1944,6 +1944,7 @@ Init_VM(void)
/* ::VM */
rb_cRubyVM = rb_define_class(“RubyVM”, rb_cObject);
rb_undef_alloc_func(rb_cRubyVM); -
rb_undef_method(CLASS_OF(rb_cRubyVM), “new”);
/* ::VM::FrozenCore /
fcore = rb_class_new(rb_cBasicObject);
@@ -1962,6 +1963,7 @@ Init_VM(void)
/ ::VM::Env */
rb_cEnv = rb_define_class_under(rb_cRubyVM, “Env”, rb_cObject);
rb_undef_alloc_func(rb_cEnv); -
rb_undef_method(CLASS_OF(rb_cEnv), “new”);
/* ::Thread */
rb_cThread = rb_define_class(“Thread”, rb_cObject);